diff --git a/src/Appwrite/Utopia/Database/RuntimeQuery.php b/src/Appwrite/Utopia/Database/RuntimeQuery.php index 369006d9df..f554c31661 100644 --- a/src/Appwrite/Utopia/Database/RuntimeQuery.php +++ b/src/Appwrite/Utopia/Database/RuntimeQuery.php @@ -44,8 +44,7 @@ class RuntimeQuery extends Query return false; } - $values = $query->getValues(); - return count($values) === 1 && $values[0] === '*'; + return $query->getAttribute() === '*'; } /** @@ -83,8 +82,7 @@ class RuntimeQuery extends Query // Check for select("*") upfront foreach ($queries as $query) { if ($query->getMethod() === Query::TYPE_SELECT) { - $values = $query->getValues(); - if (count($values) === 1 && $values[0] === '*') { + if ($query->getAttribute() === '*') { return ['type' => 'selectAll']; } } diff --git a/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php b/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php index f7d73eb287..0f923b3789 100644 --- a/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php +++ b/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php @@ -638,41 +638,27 @@ class RuntimeQueryTest extends TestCase // TYPE_SELECT tests - select("*") means "listen to all events" public function testSelectAllIsAllowed(): void { - $query = Query::select(['*']); + $query = Query::select('*'); $this->assertTrue(RuntimeQuery::isSelectAll($query)); } - public function testSelectSpecificFieldsNotAllowed(): void - { - $query = Query::select(['name', 'age']); - $this->assertFalse(RuntimeQuery::isSelectAll($query)); - } - public function testSelectSingleFieldNotAllowed(): void { - $query = Query::select(['name']); + $query = Query::select('name'); $this->assertFalse(RuntimeQuery::isSelectAll($query)); } public function testValidateSelectQueryWithWildcard(): void { - $query = Query::select(['*']); + $query = Query::select('*'); // Should not throw RuntimeQuery::validateSelectQuery($query); $this->assertTrue(true); } - public function testValidateSelectQueryWithSpecificFields(): void - { - $query = Query::select(['name', 'age']); - $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('Only select("*") is allowed in Realtime queries'); - RuntimeQuery::validateSelectQuery($query); - } - public function testValidateSelectQueryWithSingleField(): void { - $query = Query::select(['name']); + $query = Query::select('name'); $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Only select("*") is allowed in Realtime queries'); RuntimeQuery::validateSelectQuery($query); @@ -700,7 +686,7 @@ class RuntimeQueryTest extends TestCase // Filter tests with select("*") public function testFilterWithSelectAllReturnsPayload(): void { - $query = Query::select(['*']); + $query = Query::select('*'); $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter([$query], $payload); $this->assertEquals($payload, $result); @@ -710,7 +696,7 @@ class RuntimeQueryTest extends TestCase { // If select("*") is present, it should return payload regardless of other queries $queries = [ - Query::select(['*']), + Query::select('*'), Query::equal('name', ['Jane']), // This would normally fail ]; $payload = ['name' => 'John', 'age' => 30]; @@ -721,7 +707,7 @@ class RuntimeQueryTest extends TestCase public function testFilterWithSelectAllOnEmptyPayload(): void { - $query = Query::select(['*']); + $query = Query::select('*'); $payload = []; $result = $this->compileAndFilter([$query], $payload); $this->assertEquals($payload, $result);