$query = \Drupal::entityQuery('node'); $group = $query->orConditionGroup() ->condition('field_ref1_user.entity:user.uid', $user->id()) ->condition('field_ref2_user.entity:user.uid', $user->id()); $ids = $query ->condition('status', 1) ->condition('type', 'mynodetype') ->condition($group) ->execute();
The first condition in $group met 3 nodes and the second condition met 1 additional node (different from 3 nodes of condition 1) so since it is OR condition I expect to get 4 node IDs but I receive only 3 node IDs that met the first $group condition.
If I switch the conditions within the $group, I get 1 node ID, that met the first condition. It's seems that the second condition in the group is ignored.
What is wrong with my code? Is there a way to see the query that actually executed?
Edit I have activated WebProfiler to see the actual query.
WHERE (node_field_data.status = '1') AND (node_field_data.type = 'mynodetype') AND ((users_field_data.uid = '11') or (users_field_data.uid = '11'))
These are 2 different user reference fields but for both of them the query checks
users_field_data.uid = '11'