1
0
Fork 0
mirror of synced 2024-10-02 10:16:27 +13:00

Fail validation on nested attribute query

This commit is contained in:
Jake Barnby 2023-04-11 15:40:14 +12:00
parent acbdb06b3c
commit 5485346b5e
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 8 additions and 9 deletions

View file

@ -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);

View file

@ -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

View file

@ -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']);