유스 케이스에는 고유 어휘를 참조하는 두 개의 필드가있는 엔티티가 있습니다.
뉴스 :-태그 (엔티티 참조)-카테고리 (엔티티 참조)
해당 참조 중 하나를 쿼리하면 결과가 표시되지만 둘 다 (AND 필터)를 쿼리하면 결과가 표시되지 않습니다. 지금까지 그것을 세 번 확인했으며 쿼리중인 태그와 카테고리를 모두 포함하는 엔티티가 있습니다.
이것은 사용자 오류입니까 아니면 Drupal 버그입니까?
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'news')
;
$group = $query->andConditionGroup()
->condition('field_tag.entity.name', ['cars'], 'IN')
->condition('field_category.entity.name', ['sport'], 'IN')
;
$query->condition($group);
$nids = $query->execute();
편집 : entity.value 대신 원시 값을 쿼리하여 해결 방법을 찾았습니다. 이것은 바람직하지 않은 상황이지만
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'news')
;
$group = $query->andConditionGroup()
->condition('field_tag.entity.name', ['cars'], 'IN')
->condition('field_category', [1], 'IN')
;
$query->condition($group);
$nids = $query->execute();