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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

casey created an issue. See original summary.

casey’s picture

Status: Active » Needs review
FileSize
733 bytes
jrockowitz’s picture

@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);

jrockowitz’s picture

I now see how to duplicate the issue... go to a webform node and search the submissions.

jrockowitz’s picture

Here is the same patch using $submission_storage->addQueryConditions($sub_query, $this->webform);.

  • jrockowitz committed 0eb8466 on 8.x-5.x authored by casey
    Issue #2877335 by casey, jrockowitz: Cannot search in submissions for a...
jrockowitz’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.