Cannot sort table columns in views for simple math fields

Created on 25 July 2023, over 1 year ago

Problem/Motivation

I want to sort a column in a table view of a simple math field.

Steps to reproduce

Add a simple math field to a table view, check it to be sortable, try and sort column.

I've come across the issue in a standard table and a table using aggregation. I have a very simple math field "outstanding" (amount - paid) that it'd be nice to sort by since most of them are 0. No pagination. I get the following error on Drupal 9.5.10, I'm using storage (contrib) entity types but I'm not sure why that would impact things.

The website encountered an unexpected error. Please try again later.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Purchase Order - Invoices[purchase_order_invoices]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_views_simple_math_field' in 'order clause': SELECT "storage_field_data"."id" AS "id" FROM "storage_field_data" "storage_field_data" WHERE ("storage_field_data"."status" = :db_condition_placeholder_0) AND ("storage_field_data"."type" IN (:db_condition_placeholder_1)) ORDER BY "field_views_simple_math_field" ASC; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => wildlife_purchase_order ) in main() (line 19 of index.php).
πŸ› Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States erutan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024