Views integrartion: using a relation to an entity with trash ebaled results in SQL error

Created on 21 May 2023, about 1 year ago
Updated 25 October 2023, 8 months ago

Problem/Motivation

Error when using relation on the entity with trash enabled

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Office contact details[office_contact_details]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node_field_data.deleted' in 'where clause': SELECT "taxonomy_term_field_data"."weight" AS "taxonomy_term_field_data_weight", "taxonomy_term_field_data"."tid" AS "tid", "taxonomy_term_field_data"."langcode" AS "taxonomy_term_field_data_langcode", MIN(taxonomy_term_field_data.tid) AS "tid_1", MIN(field_office_duty_station_code_taxonomy_term_field_data.nid) AS "field_office_duty_station_code_taxonomy_term_field_data_nid" FROM "taxonomy_term_field_data" "taxonomy_term_field_data" INNER JOIN "node__field_office_duty_station_code" "node__field_office_duty_station_code" ON taxonomy_term_field_data.tid = node__field_office_duty_station_code.field_office_duty_station_code_target_id AND node__field_office_duty_station_code.deleted = :views_join_condition_0 INNER JOIN "node_field_data" "field_office_duty_station_code_taxonomy_term_field_data" ON node__field_office_duty_station_code.entity_id = field_office_duty_station_code_taxonomy_term_field_data.nid WHERE ((field_office_duty_station_code_taxonomy_term_field_data.nid = :node_field_data_nid1)) AND (("taxonomy_term_field_data"."status" = :db_condition_placeholder_1) AND ("taxonomy_term_field_data"."vid" IN (:db_condition_placeholder_2)) AND ("node_field_data"."deleted" IS NULL)) GROUP BY taxonomy_term_field_data_weight, taxonomy_term_field_data.tid, taxonomy_term_field_data_langcode ORDER BY "taxonomy_term_field_data_weight" ASC; Array ( [:node_field_data_nid1] => 576 [:db_condition_placeholder_1] => 1 [:db_condition_placeholder_2] => office_contact_details [:views_join_condition_0] => 0 ) in main() (line 19 of index.php).

Steps to reproduce

Create a view for any entity.
Add relation to another entity with trash enabled.
Views add alias to table when generating the query resulting in the error above

Proposed resolution

Replace table name with alias if used.

πŸ› Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

πŸ‡―πŸ‡΄Jordan josebc

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

Comments & Activities

Production build 0.69.0 2024