Fail validation on nested attribute query
This commit is contained in:
parent
acbdb06b3c
commit
5485346b5e
3 changed files with 8 additions and 9 deletions
|
@ -2899,13 +2899,6 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
|
|||
|
||||
$filterQueries = Query::groupByType($queries)['filters'];
|
||||
|
||||
// TODO: Remove this when we have a better way to handle nested attribute queries
|
||||
foreach ($filterQueries as $key => $query) {
|
||||
if (\str_contains($query->getAttribute(), '.')) {
|
||||
unset($filterQueries[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$documents = Authorization::skip(fn () => $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $queries));
|
||||
|
||||
$documentSecurity = $collection->getAttribute('documentSecurity', false);
|
||||
|
|
|
@ -18,6 +18,8 @@ class Filter extends Base
|
|||
*/
|
||||
protected $schema = [];
|
||||
|
||||
private int $maxValuesCount;
|
||||
|
||||
/**
|
||||
* Query constructor
|
||||
*
|
||||
|
@ -38,6 +40,12 @@ class Filter extends Base
|
|||
// For relationships, just validate the top level.
|
||||
// Utopia will validate each nested level during the recursive calls.
|
||||
$attribute = \explode('.', $attribute)[0];
|
||||
|
||||
// TODO: Remove this when nested queries are supported
|
||||
if (isset($this->schema[$attribute])) {
|
||||
$this->message = 'Cannot query nested attribute on: ' . $attribute;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Search for attribute in schema
|
||||
|
|
|
@ -1040,8 +1040,6 @@ class DatabaseServerTest extends Scope
|
|||
'x-appwrite-project' => $projectId,
|
||||
], $this->getHeaders()), $gqlPayload);
|
||||
|
||||
\var_dump($attributes['body']);
|
||||
|
||||
$this->assertArrayNotHasKey('errors', $attributes['body']);
|
||||
$this->assertIsArray($attributes['body']['data']);
|
||||
$this->assertIsArray($attributes['body']['data']['databasesListAttributes']);
|
||||
|
|
Loading…
Reference in a new issue