From 801724e90e01191edb38ad39711482bbd0814460 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 15 Oct 2024 15:50:02 +0300 Subject: [PATCH 1/6] APP_DATABASE_QUERY_VALUES --- app/init.php | 10 ++-- composer.json | 2 +- composer.lock | 54 +++++++++++-------- .../Database/Validator/Queries/Base.php | 2 +- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/app/init.php b/app/init.php index c2777f36f1..dcf9a21f56 100644 --- a/app/init.php +++ b/app/init.php @@ -130,6 +130,7 @@ const APP_DATABASE_ATTRIBUTE_INT_RANGE = 'intRange'; const APP_DATABASE_ATTRIBUTE_FLOAT_RANGE = 'floatRange'; const APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH = 1_073_741_824; // 2^32 bits / 4 bits per char const APP_DATABASE_TIMEOUT_MILLISECONDS = 15_000; +const APP_DATABASE_QUERY_VALUES = 100; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_BUILDS = '/storage/builds'; @@ -1398,7 +1399,8 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, $database ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) - ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); + ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS) + ->setMaxQueryValues(APP_DATABASE_QUERY_VALUES); try { $dsn = new DSN($project->getAttribute('database')); @@ -1434,7 +1436,8 @@ App::setResource('dbForConsole', function (Group $pools, Cache $cache) { ->setNamespace('_console') ->setMetadata('host', \gethostname()) ->setMetadata('project', 'console') - ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); + ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS) + ->setMaxQueryValues(APP_DATABASE_QUERY_VALUES); return $database; }, ['pools', 'cache']); @@ -1458,7 +1461,8 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, $database ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) - ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS); + ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS) + ->setMaxQueryValues(APP_DATABASE_QUERY_VALUES); if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { $database diff --git a/composer.json b/composer.json index 813e9feff2..e12fc531ec 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.6", + "utopia-php/database": "dev-0.53.x-max-query-size as 0.53.6", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 7213e1ecd5..6f9b7eb6cd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5fef87b7ea4352869a502d1570bd43e7", + "content-hash": "59f5ddee3c1259ce3f63762f2f064cc6", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.6", + "version": "dev-0.53.x-max-query-size", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "feddc8e808eaea9a11c65cca3f01683def422f52" + "reference": "7c15e2ba06e82d7daeb4edbf43564b435324a7d4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/feddc8e808eaea9a11c65cca3f01683def422f52", - "reference": "feddc8e808eaea9a11c65cca3f01683def422f52", + "url": "https://api.github.com/repos/utopia-php/database/zipball/7c15e2ba06e82d7daeb4edbf43564b435324a7d4", + "reference": "7c15e2ba06e82d7daeb4edbf43564b435324a7d4", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.6" + "source": "https://github.com/utopia-php/database/tree/0.53.x-max-query-size" }, - "time": "2024-10-08T02:18:46+00:00" + "time": "2024-10-15T12:20:07+00:00" }, { "name": "utopia-php/domains", @@ -2070,16 +2070,16 @@ }, { "name": "utopia-php/logger", - "version": "0.6.1", + "version": "0.6.2", "source": { "type": "git", "url": "https://github.com/utopia-php/logger.git", - "reference": "7e8ff512c6f04577aba1df67c7b9628971946f9c" + "reference": "25b5bd2ad8bb51292f76332faa7034644fd0941d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/logger/zipball/7e8ff512c6f04577aba1df67c7b9628971946f9c", - "reference": "7e8ff512c6f04577aba1df67c7b9628971946f9c", + "url": "https://api.github.com/repos/utopia-php/logger/zipball/25b5bd2ad8bb51292f76332faa7034644fd0941d", + "reference": "25b5bd2ad8bb51292f76332faa7034644fd0941d", "shasum": "" }, "require": { @@ -2118,9 +2118,9 @@ ], "support": { "issues": "https://github.com/utopia-php/logger/issues", - "source": "https://github.com/utopia-php/logger/tree/0.6.1" + "source": "https://github.com/utopia-php/logger/tree/0.6.2" }, - "time": "2024-09-20T14:02:12+00:00" + "time": "2024-10-14T16:02:49+00:00" }, { "name": "utopia-php/messaging", @@ -3847,6 +3847,7 @@ "issues": "https://github.com/phpbench/dom/issues", "source": "https://github.com/phpbench/dom/tree/0.3.3" }, + "abandoned": true, "time": "2023-03-06T23:46:57+00:00" }, { @@ -4194,16 +4195,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.32.0", + "version": "1.33.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", - "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/82a311fd3690fb2bf7b64d5c98f912b3dd746140", + "reference": "82a311fd3690fb2bf7b64d5c98f912b3dd746140", "shasum": "" }, "require": { @@ -4235,9 +4236,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.32.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.33.0" }, - "time": "2024-09-26T07:23:32+00:00" + "time": "2024-10-13T11:25:22+00:00" }, { "name": "phpunit/php-code-coverage", @@ -7002,9 +7003,18 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [], + "aliases": [ + { + "package": "utopia-php/database", + "version": "dev-0.53.x-max-query-size", + "alias": "0.53.6", + "alias_normalized": "0.53.6.0" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "utopia-php/database": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -7028,5 +7038,5 @@ "platform-overrides": { "php": "8.3" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index a3555c08dd..7dc1bb6800 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -66,7 +66,7 @@ class Base extends Queries new Limit(), new Offset(), new Cursor(), - new Filter($attributes), + new Filter($attributes, APP_DATABASE_QUERY_VALUES), new Order($attributes), ]; From 20800d760bc0d0bc76c4482e4d190748707acef2 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 15 Oct 2024 15:56:12 +0300 Subject: [PATCH 2/6] Set to 500 --- app/init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/init.php b/app/init.php index dcf9a21f56..e3c9cb374a 100644 --- a/app/init.php +++ b/app/init.php @@ -130,7 +130,7 @@ const APP_DATABASE_ATTRIBUTE_INT_RANGE = 'intRange'; const APP_DATABASE_ATTRIBUTE_FLOAT_RANGE = 'floatRange'; const APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH = 1_073_741_824; // 2^32 bits / 4 bits per char const APP_DATABASE_TIMEOUT_MILLISECONDS = 15_000; -const APP_DATABASE_QUERY_VALUES = 100; +const APP_DATABASE_QUERY_VALUES = 500; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_BUILDS = '/storage/builds'; From c9e2be0e08d63f88c0064d78be099fffd8c25479 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 15 Oct 2024 16:35:26 +0300 Subject: [PATCH 3/6] Fix failing test --- tests/e2e/Services/Databases/DatabasesBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 04f2dbd8c8..39ba3b04df 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -2096,7 +2096,7 @@ trait DatabasesBase */ $conditions = []; - for ($i = 0; $i < 101; $i++) { + for ($i = 0; $i < APP_DATABASE_QUERY_VALUES + 1; $i++) { $conditions[] = $i; } From 7a64987da72180464bdcf5f7dfa6415d86e027ff Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 15 Oct 2024 17:25:10 +0300 Subject: [PATCH 4/6] Fix message --- tests/e2e/Services/Databases/DatabasesBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 39ba3b04df..f63865d9a6 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -2109,7 +2109,7 @@ trait DatabasesBase ], ]); $this->assertEquals(400, $documents['headers']['status-code']); - $this->assertEquals('Invalid query: Query on attribute has greater than 100 values: releaseYear', $documents['body']['message']); + $this->assertEquals('Invalid query: Query on attribute has greater than '.APP_DATABASE_QUERY_VALUES.' values: releaseYear', $documents['body']['message']); $value = ''; From 16d65f32b3214be695557a93be9da816e6365caf Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 16 Oct 2024 21:35:32 +1300 Subject: [PATCH 5/6] Review fixes --- app/init.php | 8 +++--- composer.json | 2 +- composer.lock | 27 +++++++------------ .../Database/Validator/Queries/Base.php | 2 +- .../e2e/Services/Databases/DatabasesBase.php | 4 +-- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/app/init.php b/app/init.php index e3c9cb374a..eb149adc04 100644 --- a/app/init.php +++ b/app/init.php @@ -130,7 +130,7 @@ const APP_DATABASE_ATTRIBUTE_INT_RANGE = 'intRange'; const APP_DATABASE_ATTRIBUTE_FLOAT_RANGE = 'floatRange'; const APP_DATABASE_ATTRIBUTE_STRING_MAX_LENGTH = 1_073_741_824; // 2^32 bits / 4 bits per char const APP_DATABASE_TIMEOUT_MILLISECONDS = 15_000; -const APP_DATABASE_QUERY_VALUES = 500; +const APP_DATABASE_QUERY_MAX_VALUES = 500; const APP_STORAGE_UPLOADS = '/storage/uploads'; const APP_STORAGE_FUNCTIONS = '/storage/functions'; const APP_STORAGE_BUILDS = '/storage/builds'; @@ -1400,7 +1400,7 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForConsole, ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS) - ->setMaxQueryValues(APP_DATABASE_QUERY_VALUES); + ->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES); try { $dsn = new DSN($project->getAttribute('database')); @@ -1437,7 +1437,7 @@ App::setResource('dbForConsole', function (Group $pools, Cache $cache) { ->setMetadata('host', \gethostname()) ->setMetadata('project', 'console') ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS) - ->setMaxQueryValues(APP_DATABASE_QUERY_VALUES); + ->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES); return $database; }, ['pools', 'cache']); @@ -1462,7 +1462,7 @@ App::setResource('getProjectDB', function (Group $pools, Database $dbForConsole, ->setMetadata('host', \gethostname()) ->setMetadata('project', $project->getId()) ->setTimeout(APP_DATABASE_TIMEOUT_MILLISECONDS) - ->setMaxQueryValues(APP_DATABASE_QUERY_VALUES); + ->setMaxQueryValues(APP_DATABASE_QUERY_MAX_VALUES); if ($dsn->getHost() === System::getEnv('_APP_DATABASE_SHARED_TABLES', '')) { $database diff --git a/composer.json b/composer.json index e12fc531ec..dd5472a0fa 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.10.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "dev-0.53.x-max-query-size as 0.53.6", + "utopia-php/database": "0.53.8", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 6f9b7eb6cd..867030f289 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "59f5ddee3c1259ce3f63762f2f064cc6", + "content-hash": "18505aa5baca1170e7cbdbb2a355b173", "packages": [ { "name": "adhocore/jwt", @@ -1724,16 +1724,16 @@ }, { "name": "utopia-php/database", - "version": "dev-0.53.x-max-query-size", + "version": "0.53.8", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "7c15e2ba06e82d7daeb4edbf43564b435324a7d4" + "reference": "f4f9297d633b9f8407c6261535549bfd6024a468" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/7c15e2ba06e82d7daeb4edbf43564b435324a7d4", - "reference": "7c15e2ba06e82d7daeb4edbf43564b435324a7d4", + "url": "https://api.github.com/repos/utopia-php/database/zipball/f4f9297d633b9f8407c6261535549bfd6024a468", + "reference": "f4f9297d633b9f8407c6261535549bfd6024a468", "shasum": "" }, "require": { @@ -1774,9 +1774,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.x-max-query-size" + "source": "https://github.com/utopia-php/database/tree/0.53.8" }, - "time": "2024-10-15T12:20:07+00:00" + "time": "2024-10-16T08:16:33+00:00" }, { "name": "utopia-php/domains", @@ -7003,18 +7003,9 @@ "time": "2024-03-07T20:33:40+00:00" } ], - "aliases": [ - { - "package": "utopia-php/database", - "version": "dev-0.53.x-max-query-size", - "alias": "0.53.6", - "alias_normalized": "0.53.6.0" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "utopia-php/database": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index 7dc1bb6800..af5d59ddfd 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -66,7 +66,7 @@ class Base extends Queries new Limit(), new Offset(), new Cursor(), - new Filter($attributes, APP_DATABASE_QUERY_VALUES), + new Filter($attributes, APP_DATABASE_QUERY_MAX_VALUES), new Order($attributes), ]; diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index f63865d9a6..6d8622276e 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -2096,7 +2096,7 @@ trait DatabasesBase */ $conditions = []; - for ($i = 0; $i < APP_DATABASE_QUERY_VALUES + 1; $i++) { + for ($i = 0; $i < APP_DATABASE_QUERY_MAX_VALUES + 1; $i++) { $conditions[] = $i; } @@ -2109,7 +2109,7 @@ trait DatabasesBase ], ]); $this->assertEquals(400, $documents['headers']['status-code']); - $this->assertEquals('Invalid query: Query on attribute has greater than '.APP_DATABASE_QUERY_VALUES.' values: releaseYear', $documents['body']['message']); + $this->assertEquals('Invalid query: Query on attribute has greater than '.APP_DATABASE_QUERY_MAX_VALUES.' values: releaseYear', $documents['body']['message']); $value = ''; From 45c8584903e36b37022a6b35fb165c0a96913d57 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 16 Oct 2024 21:36:18 +1300 Subject: [PATCH 6/6] Update migration --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 867030f289..9079512e60 100644 --- a/composer.lock +++ b/composer.lock @@ -2175,16 +2175,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.8", + "version": "0.6.9", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "c3740de52c1b616aa7f054d0fadb9207895b5279" + "reference": "ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/c3740de52c1b616aa7f054d0fadb9207895b5279", - "reference": "c3740de52c1b616aa7f054d0fadb9207895b5279", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b", + "reference": "ce97cdf2ca82e7cec78e2ed484ef2c71ebe8744b", "shasum": "" }, "require": { @@ -2225,9 +2225,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.8" + "source": "https://github.com/utopia-php/migration/tree/0.6.9" }, - "time": "2024-10-10T08:09:19+00:00" + "time": "2024-10-16T08:33:21+00:00" }, { "name": "utopia-php/mongo",