Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens:
SELECT gc.entity_id AS entity_id FROM {group_content_field_data} gc WHERE type = :db_condition_placeholder_0:db_condition_placeholder_1; Array ( [:db_condition_placeholder_0] => group_content_type_5c237bd57772d [:db_condition_placeholder_1] => working_group-group_node-forum )
in Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (line 110 of /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php).
This query at /src/EventSubscriber/QueryAccessSubscriber.php is causing the problem
$grouped_entity_ids = $this->database
->select('group_content_field_data', 'gc')
->fields('gc', ['entity_id'])
->condition('type', $group_content_type_ids)
->execute()
->fetchCol();
$group_content_type_ids is an array, and for my case, $group_content_type_ids it has 2 elements. When this query executed, it seems to concatenate two values to one, so it complains for number of bound variables does not match number of tokens
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | group-3157572-8.patch | 26.83 KB | kristiaanvandeneynde |
Comments
Comment #2
fonant commentedShould be generating "
WHERE type IN (:db_condition_placeholder_0, :db_condition_placeholder_1);" if the second condition argument is an array, I think? Perhaps we need to explicitly set "IN" as the comparison operator as a third argument to the ->condition() method?Comment #3
cyoon84 commentedComment #4
cyoon84 commented@fonant yes, that's what I thought too. My just uploaded patch includes 'IN' in condition part.
Comment #5
cyoon84 commentedComment #6
fonant commentedPatch from #3 fixes the problem for me here.
Comment #7
kristiaanvandeneyndeIt's actually happening all over that function. Forgot the database layer requires you to be specific about IN queries. Going to try and adjust some tests so they would trigger these errors.
Comment #8
kristiaanvandeneyndeThis fixes all sorts of issues. Affected tests went red without the changes and green with, let's see what the whole test suite has to say.
Comment #9
kristiaanvandeneynde