Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 313486

Entity query using OR group with the same field name on different relationships doesn't work

$
0
0

Problem/Motivation

When using a condition OR group, using two different relationship conditions, but filtering on the same field name on both relationships. You get incorrect results. Only the first condition is properly applied, and not the second.

Steps to reproduce

Node type page has two fields:
field_first_relationship
field_second_relationship

Each one is an entity reference to a different Taxonomy vocabulary (I haven't tried whether this issue exists if both pointing to the same vocab, I assume it will do though).

On both taxonomy vocabs there's a field field_boolean

Entity query:

$query = Drupal::entityQuery('node');
$group = $query->orConditionGroup()
  ->condition('field_first_relationship.entity:taxonomy_term.field_boolean', 1)
  ->condition('field_second_relationship.entity:taxonomy_term.field_boolean', 1);
$query->condition($group);
$results = $query->execute();

Expected results:
I should get back all nodes that have a reference on either field to a taxonomy term with field_boolean: 1

Actual results:
I only get back nodes with a reference on field_first_relationship to a taxonomy term with field_boolean: 1.
field_second_relationship is ignored.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 313486

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>