Problem/Motivation
The patch from the parent issue works perfectly for ::loadByProperties() as it expects and array of values and will add IN operator, in my case I am facing the same problem using ::entityQuery(),
Steps to reproduce
Being more specific, I'm working with the menu_export module (and PostgreSQL of course) and it has this query:
$menuLinkEntity = \Drupal::entityQuery('menu_link_content')
->accessCheck(FALSE)
->condition('uuid', $menu['uuid'])
->execute();
Where $menu['uuid'] is an array of values.
The problem with this is that the condition operator is not defined, and when the translateCondition() is executed, it didn't add the operator, which should be "IN", causing this error:
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "("
LINE 5: WHERE (LOWER("menu_link_content"."uuid") (LOWER('XXXXXProposed resolution
Not sure if it should be a core or module issue, I added a patch that worked for me.
I added the IN operator if $condition['operator'] is empty:
if (empty($condition['operator'])) {
$condition['operator'] = 'IN';
}
I didn't have enough time to add a test, it would be something like this:
$node1 = $this->drupalCreateNode([
'type' => 'page',
'field_first' => '1234',
'field_second' => 'test_value_1',
]);
$nodes = $this->container->get('entity_type.manager')->getStorage('node')->getQuery()->condition('uuid',[$node1->uuid()])->execute();
// @todo validate results
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3382082-2.patch | 799 bytes | luisnicg |
Comments
Comment #2
luisnicg commentedComment #3
luisnicg commentedComment #4
catchThis should be fixed in the module by adding an explicit IN operator, see https://www.drupal.org/node/3350985
Comment #5
luisnicg commentedThanks for the quick response and feedback on comment #4, I already created the bug in the module.