entityQuery is broken on PostgreSQL when importing menus

Created on 20 August 2023, 10 months ago

Problem/Motivation

I had added the issue to the core, but according to the feedback, this bug should be fixed in the module. Here is the main issue:
https://www.drupal.org/project/drupal/issues/3382082 πŸ› entityQuery is broken on PostgreSQL when using array of values with case insensitive properties Active

More context about the causes can be found here:
https://www.drupal.org/node/3350985 β†’

In the submission of the import form there is an ::entityQuery() with a condition that looks for the uuid based on an array of values, this condition requires to execute the translateCondition() function during the compile() process.

This condition causes a syntax error on PostgreSQL since the operator is not defined, here is the condition

    $menuLinkEntity = \Drupal::entityQuery('menu_link_content')
      ->accessCheck(FALSE)
      ->condition('uuid', $menu['uuid'])
      ->execute();

Steps to reproduce

Use entityQuery() with an array of values, when using a sensitive case field without specifying an operator.

It only happens on PostgreSQL

    $nodes = \Drupal::entityQuery('node')
      ->condition('uuid', $uuid_array)
      ->execute();

Proposed resolution

The operator needs to be specified.

    $menuLinkEntity = \Drupal::entityQuery('menu_link_content')
      ->accessCheck(FALSE)
      ->condition('uuid', $menu['uuid'], 'IN')
      ->execute();

Another possible solution could be to send the value instead of the array:

    $menuLinkEntity = \Drupal::entityQuery('menu_link_content')
      ->accessCheck(FALSE)
      ->condition('uuid', $menu['uuid']['value'])
      ->execute();
πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡²πŸ‡½Mexico luisnicg

Live updates comments and jobs are added and updated live.
  • PostgreSQL

    Particularly affects sites running on the PostgreSQL database.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024