Problem/Motivation
It's not possible to search in the submission lsit of a specific node. It throws an exception:
Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'entity_type' in where clause is ambiguous: SELECT COUNT(*) AS expression FROM (SELECT 1 AS expression FROM {webform_submission} base_table INNER JOIN {webform_submission} webform_submission ON webform_submission.sid = base_table.sid LEFT JOIN {webform_submission} webform_submission_2 ON webform_submission_2.sid = base_table.sid WHERE (webform_submission.webform_id = :db_condition_placeholder_0) AND (webform_submission.entity_type LIKE :db_condition_placeholder_1 ESCAPE '\\') AND (webform_submission.entity_id LIKE :db_condition_placeholder_2 ESCAPE '\\') AND( (webform_submission_2.sid IN (SELECT sd.sid AS sid FROM {webform_submission_data} sd WHERE (value LIKE :db_condition_placeholder_3 ESCAPE '\\') AND (webform_id = :db_condition_placeholder_4) AND (entity_type = :db_condition_placeholder_5) AND (entity_id = :db_condition_placeholder_6) )) or (webform_submission_2.notes LIKE :db_condition_placeholder_7 ESCAPE '\\') )) subquery
Proposed resolution
WebformSubmissionListBuilder::getQuery() uses WebformSubmissionStorage::addQueryConditions() on the subquery on webform_submission_data to search for given search keys. It only needs the condition on webform_id.
Replace the incorrect call to WebformSubmissionStorage::addQueryConditions() with a single condition on the subquery.
Remaining tasks
Tests?
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#5 | cannot_search_in-2877335-5.patch | 745 bytes | jrockowitz |
| |||
#2 | 2877335.patch | 733 bytes | casey |
|
Comments
Comment #2
casey CreditAttribution: casey at SWIS commentedComment #3
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented@casey I need some more information on how to reproduce this issue (ie URL) before we start altering these queries.
I understand that the 'webform_submission_data' does not contain the source_entity or uid columns.
I think you can just use...
$submission_storage->addQueryConditions($sub_query, $this->webform);
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI now see how to duplicate the issue... go to a webform node and search the submissions.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedHere is the same patch using
$submission_storage->addQueryConditions($sub_query, $this->webform);
.Comment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented