1
0
Fork 0
mirror of synced 2024-05-20 12:42:39 +12:00

Merge pull request #2526 from appwrite/fix-query-value-limits

fix: database query value limits
This commit is contained in:
Torsten Dittmann 2021-12-29 15:18:49 +01:00 committed by GitHub
commit 21158e5a96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -1717,7 +1717,15 @@ App::get('/v1/database/collections/:collectionId/documents')
}
}
$queries = \array_map(fn ($query) => Query::parse($query), $queries);
$queries = \array_map(function ($query) {
$query = Query::parse($query);
if (\count($query->getValues()) > 100) {
throw new Exception("You cannot use more than 100 query values on attribute '{$query->getAttribute()}'", 400);
}
return $query;
}, $queries);
if (!empty($queries)) {
$validator = new QueriesValidator(new QueryValidator($collection->getAttribute('attributes', [])), $collection->getAttribute('indexes', []), true);

View file

@ -1212,6 +1212,21 @@ trait DatabaseBase
$this->assertEquals(400, $documents['headers']['status-code']);
$this->assertEquals('Index not found: actors', $documents['body']['message']);
$conditions = [];
for ($i=0; $i < 101; $i++) {
$conditions[] = $i;
}
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'queries' => ['releaseYear.equal(' . implode(',', $conditions) . ')'],
]);
$this->assertEquals(400, $documents['headers']['status-code']);
return [];
}