Problem/Motivation
After sorting some fields
The website encountered an unexpected error. Try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Frontpage[frontpage]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'unknown' in 'ORDER BY': SELECT "node_field_data"."langcode" AS "node_field_data_langcode", "node_field_data"."nid" AS "nid" FROM "node_field_data" "node_field_data" ORDER BY "unknown" ASC LIMIT 20 OFFSET 0; Array ( ) in main() (line 19 of index.php).
Check all descriptions of the error in the attached photo.
Steps to reproduce
1. Create a View and set the Format to "FooTable".
2. Add a non-database field to the View (e.g., "Global: View result counter").
3. Go to the FooTable Format Settings and enable sorting for this specific column.
4. Save the View and navigate to the View page.
5. Click on the column header to sort.
6. The fatal DatabaseExceptionWrapper error is thrown.
Proposed resolution
The FooTable style plugin should check if a field is actually a sortable database column before attempting to alter the SQL query.
Non-database fields should either be disabled from being selected for sorting in the plugin settings form to prevent fatal errors.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| sorting_error_footable.png | 219.22 KB | just-me |
Issue fork footable-3586493
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
just-me commentedComment #4
just-me commentedI've added a check if fields are sortable in the src/Plugin/views/style/FooTable.php for the buildOptionsForm method. This step hides the sortable checkbox for the counter. Please review it. Main bug is described here https://www.drupal.org/project/drupal/issues/3574506.
Comment #5
just-me commentedSorry, it was the wrong status. Updated it to Needs review.
Comment #6
just-me commentedThe MR was updated according to the suggestions. Please review it.
Comment #7
quadrexdevLooks good
Comment #9
just-me commentedMerged to 8.x-2.x. Thanks to everyone.