fix compile

This commit is contained in:
fogelito
2026-02-08 11:53:56 +02:00
parent 1762b9d2ec
commit b0e47fbb2c
2 changed files with 9 additions and 25 deletions
@@ -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'];
}
}
@@ -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);