How to reproduce:
- Create a fresh Drupal 8.0.3 site, standard installation
- Enable Languages, enable language selection for content type "page"
- Create a new view, leave view settings as is
- Add filter criteria "Translation language" "Is one of" "Content language selected for page" (or any other, doesnt matter really)
- Add the display "Entity Reference Source", select "Title" for the Format settings
- Add a content reference field to "page" content type
- Select the just created view as reference selection
- Create a new content of type "page" with title "test", save
- Create a new content of type "page", enter "test" in the autocomplete reference field
- Select "test" in the autocomplete reference field
- save the node
=> This will result in a sql error, because the verify function adds the selected entity id's to the views query without properly masking "nid". The error should also trigger on other filters that join tables on nid.
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT node_field_data.title AS node_field_data_title, node_field_data.nid AS nid FROM {node_field_data} node_field_data INNER JOIN {node} node ON node_field_data.nid = node.nid WHERE (( (nid IN (:db_condition_placeholder_0)) )AND(( (node_field_data.type IN (:db_condition_placeholder_1)) AND (node.langcode IN (:db_condition_placeholder_2)) ))) ORDER BY node_field_data_title DESC; Array ( [:db_condition_placeholder_0] => 36 [:db_condition_placeholder_1] => page [:db_condition_placeholder_2] => en ) in Drupal\Core\Database\Connection->handleQueryException() (line 673 of core/lib/Drupal/Core/Database/Connection.php).
Comments
Comment #2
lendudeMarking as duplicate of #2669590: IntegrityConstraintViolationException using an entity reference in a view with a entity reference display, and moving to the right queue.