Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
If I have a multi-valued fields, say 'tags', then AFAICT an entity query can't find me entities which do not have the tag ID 123 in that field.
This doesn't work:
$query = \Drupal::service('entity_type.manager')->getStorage('node')->getQuery()
->condition('tags', 123, '<>');
$ids = $query->execute();
It's possible to do this in SQL by joining to the field table with the field value in the JOIN clause, and then filtering out.
SELECT * FROM node n
LEFT JOIN node__tags t ON n.nid = t.entity_id AND t.value = 123
WHERE t.value IS NULL
Is this something that could be added to entity queries?
Comments
Comment #11
j.cowher CreditAttribution: j.cowher commentedI am also experiencing this.
Comment #13
John Pitcairn CreditAttribution: John Pitcairn commentedArgh. Yes. Makes querying core list fields for the absence of a value more difficult than expected.