Database exception: ORDER BY clause is not in SELECT list

Created on 16 December 2022, over 2 years ago
Updated 17 April 2025, about 2 months ago

Similar issue to the related one posted on the Forum Access issue queue. Was not causing problems on my local environment so didn't discover until it was pushed to a hosted environment. Anyway, the comments on the related issue helped me find a fix for this.

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 3065 Expression #1 of ORDER BY clause is not in SELECT list, references column 'mysite_kK4zH.t.weight' which is not in SELECT list; this is incompatible with DISTINCT: SELECT DISTINCT "t"."tid" AS "tid", "t"."name" AS "name", "t"."vid" AS "vocabulary_machine_name" FROM "taxonomy_term_field_data" "t" INNER JOIN "taxonomy_term__parent" "p" ON t.tid = p.entity_id LEFT OUTER JOIN "forum_access" "fa" ON fa.tid = t.tid LEFT OUTER JOIN "acl" "acl" ON acl.figure = t.tid AND acl.module = 'forum_access' AND acl.name=:name LEFT OUTER JOIN "acl_user" "aclu" ON aclu.acl_id = acl.acl_id AND aclu.uid = :uid WHERE ("t"."vid" = :db_condition_placeholder_0) AND ("p"."parent_target_id" = :db_condition_placeholder_1) AND (("fa"."rid" IS NULL) OR (("fa"."rid" IN (:db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) AND ("fa"."grant_view" >= :db_condition_placeholder_6)) OR ("aclu"."uid" = :db_condition_placeholder_7)) ORDER BY "t"."weight" ASC, "t"."name" ASC; Array ([ ....whole bunch of conditions removed for this issue report.... ]) in _term_reference_tree_get_children() (line 287 of /app/web/modules/contrib/term_reference_tree/term_reference_tree.module).

🐛 Bug report
Status

Active

Version

1.1

Component

Code

Created by

🇬🇧United Kingdom david.qdoscc

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024