Issue #3320240 by solideogloria, tobiasb, smustgrave, alexpott: Entity count query returns a string instead of int

(cherry picked from commit c1891492e4)
merge-requests/2280/head
catch 2022-11-28 22:05:36 +00:00
parent 8aab026e68
commit f339daf71b
2 changed files with 7 additions and 7 deletions

View File

@ -264,7 +264,7 @@ class Query extends QueryBase implements QueryInterface {
*/ */
protected function result() { protected function result() {
if ($this->count) { if ($this->count) {
return $this->sqlQuery->countQuery()->execute()->fetchField(); return (int) $this->sqlQuery->countQuery()->execute()->fetchField();
} }
// Return a keyed array of results. The key is either the revision_id or // Return a keyed array of results. The key is either the revision_id or
// the entity_id depending on whether the entity type supports revisions. // the entity_id depending on whether the entity type supports revisions.

View File

@ -191,7 +191,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->condition("$figures.color", 'red') ->condition("$figures.color", 'red')
->sort('id'); ->sort('id');
$count_query = clone $query; $count_query = clone $query;
$this->assertEquals(12, $count_query->count()->execute()); $this->assertSame(12, $count_query->count()->execute());
$this->queryResults = $query->execute(); $this->queryResults = $query->execute();
// Now bit 0 (1, 3, 5, 7, 9, 11, 13, 15) or bit 2 (4, 5, 6, 7, 12, 13, 14, // Now bit 0 (1, 3, 5, 7, 9, 11, 13, 15) or bit 2 (4, 5, 6, 7, 12, 13, 14,
// 15) needs to be set. // 15) needs to be set.
@ -451,7 +451,7 @@ class EntityQueryTest extends EntityKernelTestBase {
// 13 red tr // 13 red tr
// 15 red tr // 15 red tr
$count_query = clone $query; $count_query = clone $query;
$this->assertEquals(15, $count_query->count()->execute()); $this->assertSame(15, $count_query->count()->execute());
$this->queryResults = $query->execute(); $this->queryResults = $query->execute();
$this->assertResult(8, 12, 4, 2, 3, 10, 11, 14, 15, 6, 7, 1, 9, 13, 5); $this->assertResult(8, 12, 4, 2, 3, 10, 11, 14, 15, 6, 7, 1, 9, 13, 5);
@ -480,7 +480,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->sort("$greetings.format", 'DESC') ->sort("$greetings.format", 'DESC')
->sort('id', 'DESC'); ->sort('id', 'DESC');
$count_query = clone $query; $count_query = clone $query;
$this->assertEquals(15, $count_query->count()->execute()); $this->assertSame(15, $count_query->count()->execute());
$this->queryResults = $query->execute(); $this->queryResults = $query->execute();
$this->assertResult(15, 13, 7, 5, 11, 9, 3, 1, 14, 6, 10, 2, 12, 4, 8); $this->assertResult(15, 13, 7, 5, 11, 9, 3, 1, 14, 6, 10, 2, 12, 4, 8);
} }
@ -576,7 +576,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->exists("$field_name.color") ->exists("$field_name.color")
->count() ->count()
->execute(); ->execute();
$this->assertEquals(0, $count); $this->assertSame(0, $count);
} }
/** /**
@ -621,7 +621,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->condition($this->figures . '.shape', 'triangle'); ->condition($this->figures . '.shape', 'triangle');
// We added 2 conditions so count should be 2. // We added 2 conditions so count should be 2.
$this->assertEquals(2, $and_condition_group->count()); $this->assertSame(2, $and_condition_group->count());
// Add an OR condition group with 2 conditions in it. // Add an OR condition group with 2 conditions in it.
$or_condition_group = $query->orConditionGroup() $or_condition_group = $query->orConditionGroup()
@ -629,7 +629,7 @@ class EntityQueryTest extends EntityKernelTestBase {
->condition($this->figures . '.shape', 'triangle'); ->condition($this->figures . '.shape', 'triangle');
// We added 2 conditions so count should be 2. // We added 2 conditions so count should be 2.
$this->assertEquals(2, $or_condition_group->count()); $this->assertSame(2, $or_condition_group->count());
} }
/** /**