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

Merge branch 'feat-database-indexing' of https://github.com/appwrite/appwrite into feat-database-indexing

This commit is contained in:
Torsten Dittmann 2021-12-29 15:49:32 +01:00
commit d8f71acc3f
3 changed files with 41 additions and 7 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);

12
composer.lock generated
View file

@ -2138,16 +2138,16 @@
},
{
"name": "utopia-php/database",
"version": "0.13.0",
"version": "0.13.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "2e13987364f4966ec8a36784d4fb5df3a84e4e78"
"reference": "a1b2849c991b6384fe70e3c2d0633256a4fb795b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/2e13987364f4966ec8a36784d4fb5df3a84e4e78",
"reference": "2e13987364f4966ec8a36784d4fb5df3a84e4e78",
"url": "https://api.github.com/repos/utopia-php/database/zipball/a1b2849c991b6384fe70e3c2d0633256a4fb795b",
"reference": "a1b2849c991b6384fe70e3c2d0633256a4fb795b",
"shasum": ""
},
"require": {
@ -2195,9 +2195,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/0.13.0"
"source": "https://github.com/utopia-php/database/tree/0.13.1"
},
"time": "2021-12-27T12:59:50+00:00"
"time": "2021-12-29T14:04:55+00:00"
},
{
"name": "utopia-php/domains",

View file

@ -1145,6 +1145,17 @@ trait DatabaseBase
$this->assertEquals(1944, $documents['body']['documents'][0]['releaseYear']);
$this->assertCount(1, $documents['body']['documents']);
$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' => ['$id.equal("' . $documents['body']['documents'][0]['$id'] . '")'],
]);
$this->assertEquals($documents['headers']['status-code'], 200);
$this->assertEquals(1944, $documents['body']['documents'][0]['releaseYear']);
$this->assertCount(1, $documents['body']['documents']);
$documents = $this->client->call(Client::METHOD_GET, '/database/collections/' . $data['moviesId'] . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -1201,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 [];
}