Skip to content

Commit 8b65299

Browse files
authored
Merge pull request appwrite#8802 from appwrite/fix-max-queries-size
Fix max queries values
2 parents 62817f5 + 3d991ed commit 8b65299

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

app/init.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
const APP_DATABASE_ATTRIBUTE_FLOAT_RANGE = 'floatRange';
131131
const APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH = 1_073_741_824; // 2^32 bits / 4 bits per char
132132
const APP_DATABASE_TIMEOUT_MILLISECONDS = 15_000;
133+
const APP_DATABASE_QUERY_MAX_VALUES = 500;
133134
const APP_STORAGE_UPLOADS = '/storage/uploads';
134135
const APP_STORAGE_FUNCTIONS = '/storage/functions';
135136
const APP_STORAGE_BUILDS = '/storage/builds';
@@ -1398,7 +1399,8 @@ function (mixed $value) {
13981399
$database
13991400
->setMetadata('host', \gethostname())
14001401
->setMetadata('project', $project->getId())
1401-
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS);
1402+
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS)
1403+
->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES);
14021404

14031405
try {
14041406
$dsn = new DSN($project->getAttribute('database'));
@@ -1434,7 +1436,8 @@ function (mixed $value) {
14341436
->setNamespace('_console')
14351437
->setMetadata('host', \gethostname())
14361438
->setMetadata('project', 'console')
1437-
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS);
1439+
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS)
1440+
->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES);
14381441

14391442
return $database;
14401443
}, ['pools', 'cache']);
@@ -1458,7 +1461,8 @@ function (mixed $value) {
14581461
$database
14591462
->setMetadata('host', \gethostname())
14601463
->setMetadata('project', $project->getId())
1461-
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS);
1464+
->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS)
1465+
->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES);
14621466

14631467
if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) {
14641468
$database

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Appwrite/Utopia/Database/Validator/Queries/Base.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(string $collection, array $allowedAttributes)
6666
new Limit(),
6767
new Offset(),
6868
new Cursor(),
69-
new Filter($attributes),
69+
new Filter($attributes, APP_DATABASE_QUERY_MAX_VALUES),
7070
new Order($attributes),
7171
];
7272

tests/e2e/Services/Databases/DatabasesBase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,7 @@ public function testDocumentsListQueries(array $data): array
20962096
*/
20972097
$conditions = [];
20982098

2099-
for ($i = 0; $i < 101; $i++) {
2099+
for ($i = 0; $i < APP_DATABASE_QUERY_MAX_VALUES + 1; $i++) {
21002100
$conditions[] = $i;
21012101
}
21022102

@@ -2109,7 +2109,7 @@ public function testDocumentsListQueries(array $data): array
21092109
],
21102110
]);
21112111
$this->assertEquals(400, $documents['headers']['status-code']);
2112-
$this->assertEquals('Invalid query: Query on attribute has greater than 100 values: releaseYear', $documents['body']['message']);
2112+
$this->assertEquals('Invalid query: Query on attribute has greater than '.APP_DATABASE_QUERY_MAX_VALUES.' values: releaseYear', $documents['body']['message']);
21132113

21142114
$value = '';
21152115

0 commit comments

Comments
 (0)