Loading core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +1 −1 Changes for core/lib/Drupal/Core/Entity/Query/Sql/Tables.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ public function addField($field, $type, $langcode) { $next_index_prefix = "$relationship_specifier.$column"; } } if ($index_prefix === '' && $field_storage->getCardinality() > 1) { if ($index_prefix === '' && $field_storage->isMultiple()) { $index_prefix = $condition_prefix; } $table = $this->ensureFieldTable($index_prefix, $field_storage, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta); Loading core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php +30 −2 Changes for core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php: 30 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestMulRev; Loading Loading @@ -66,6 +67,13 @@ class EntityQueryTest extends EntityKernelTestBase { */ public $figures; /** * Field name for the unlimited cardinality figures field. * * @var string */ public $figuresUnlimited; /** * The entity_test_mulrev entity storage. * Loading @@ -84,13 +92,18 @@ protected function setUp(): void { $this->installConfig(['language']); $figures = $this->randomMachineName(); $figures_unlimited = $this->randomMachineName(); $greetings = $this->randomMachineName(); foreach ([$figures => 'shape', $greetings => 'text'] as $field_name => $field_type) { foreach ([ $figures => ['shape', 2], $figures_unlimited => ['shape', FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED], $greetings => ['text', 2], ] as $field_name => [$field_type, $cardinality]) { $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test_mulrev', 'type' => $field_type, 'cardinality' => 2, 'cardinality' => $cardinality, ]); $field_storage->save(); $field_storages[] = $field_storage; Loading Loading @@ -170,10 +183,12 @@ protected function setUp(): void { $entity->getTranslation($units[$key][1])->{$units[$key][0]}[] = $units[$key][2]; } } $entity->{$figures_unlimited} = $entity->{$figures}->getValue(); $entity->save(); } $this->bundles = $bundles; $this->figures = $figures; $this->figuresUnlimited = $figures_unlimited; $this->greetings = $greetings; $this->storage = $this->container->get('entity_type.manager')->getStorage('entity_test_mulrev'); } Loading @@ -184,6 +199,7 @@ protected function setUp(): void { public function testEntityQuery(): void { $greetings = $this->greetings; $figures = $this->figures; $figures_unlimited = $this->figuresUnlimited; $this->queryResults = $this->storage ->getQuery() ->accessCheck(FALSE) Loading Loading @@ -258,6 +274,18 @@ public function testEntityQuery(): void { // Unit 0 and unit 1, so bits 0 1. $this->assertResult(3, 7, 11, 15); // Do the same test with an unlimited cardinality field. $query = $this->storage->getQuery()->accessCheck(FALSE); $group_blue = $query->andConditionGroup()->condition("$figures_unlimited.color", 'blue'); $group_red = $query->andConditionGroup()->condition("$figures_unlimited.color", 'red'); $this->queryResults = $query ->condition($group_blue) ->condition($group_red) ->sort('revision_id') ->execute(); // Unit 0 and unit 1, so bits 0 1. $this->assertResult(3, 7, 11, 15); // Do the same test but with IN operator. $query = $this->storage->getQuery()->accessCheck(FALSE); $group_blue = $query->andConditionGroup()->condition("$figures.color", ['blue'], 'IN'); Loading Loading
core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +1 −1 Changes for core/lib/Drupal/Core/Entity/Query/Sql/Tables.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -219,7 +219,7 @@ public function addField($field, $type, $langcode) { $next_index_prefix = "$relationship_specifier.$column"; } } if ($index_prefix === '' && $field_storage->getCardinality() > 1) { if ($index_prefix === '' && $field_storage->isMultiple()) { $index_prefix = $condition_prefix; } $table = $this->ensureFieldTable($index_prefix, $field_storage, $type, $langcode, $base_table, $entity_id_field, $field_id_field, $delta); Loading
core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php +30 −2 Changes for core/tests/Drupal/KernelTests/Core/Entity/EntityQueryTest.php: 30 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Entity\Query\QueryException; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\entity_test\Entity\EntityTest; use Drupal\entity_test\Entity\EntityTestMulRev; Loading Loading @@ -66,6 +67,13 @@ class EntityQueryTest extends EntityKernelTestBase { */ public $figures; /** * Field name for the unlimited cardinality figures field. * * @var string */ public $figuresUnlimited; /** * The entity_test_mulrev entity storage. * Loading @@ -84,13 +92,18 @@ protected function setUp(): void { $this->installConfig(['language']); $figures = $this->randomMachineName(); $figures_unlimited = $this->randomMachineName(); $greetings = $this->randomMachineName(); foreach ([$figures => 'shape', $greetings => 'text'] as $field_name => $field_type) { foreach ([ $figures => ['shape', 2], $figures_unlimited => ['shape', FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED], $greetings => ['text', 2], ] as $field_name => [$field_type, $cardinality]) { $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, 'entity_type' => 'entity_test_mulrev', 'type' => $field_type, 'cardinality' => 2, 'cardinality' => $cardinality, ]); $field_storage->save(); $field_storages[] = $field_storage; Loading Loading @@ -170,10 +183,12 @@ protected function setUp(): void { $entity->getTranslation($units[$key][1])->{$units[$key][0]}[] = $units[$key][2]; } } $entity->{$figures_unlimited} = $entity->{$figures}->getValue(); $entity->save(); } $this->bundles = $bundles; $this->figures = $figures; $this->figuresUnlimited = $figures_unlimited; $this->greetings = $greetings; $this->storage = $this->container->get('entity_type.manager')->getStorage('entity_test_mulrev'); } Loading @@ -184,6 +199,7 @@ protected function setUp(): void { public function testEntityQuery(): void { $greetings = $this->greetings; $figures = $this->figures; $figures_unlimited = $this->figuresUnlimited; $this->queryResults = $this->storage ->getQuery() ->accessCheck(FALSE) Loading Loading @@ -258,6 +274,18 @@ public function testEntityQuery(): void { // Unit 0 and unit 1, so bits 0 1. $this->assertResult(3, 7, 11, 15); // Do the same test with an unlimited cardinality field. $query = $this->storage->getQuery()->accessCheck(FALSE); $group_blue = $query->andConditionGroup()->condition("$figures_unlimited.color", 'blue'); $group_red = $query->andConditionGroup()->condition("$figures_unlimited.color", 'red'); $this->queryResults = $query ->condition($group_blue) ->condition($group_red) ->sort('revision_id') ->execute(); // Unit 0 and unit 1, so bits 0 1. $this->assertResult(3, 7, 11, 15); // Do the same test but with IN operator. $query = $this->storage->getQuery()->accessCheck(FALSE); $group_blue = $query->andConditionGroup()->condition("$figures.color", ['blue'], 'IN'); Loading