From 03d33601b07b1545841bf466a254fc91b5a7b212 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 14 Jun 2024 13:08:30 +1200 Subject: [PATCH] Override find --- app/cli.php | 2 +- app/config/collections.php | 2 +- app/controllers/api/account.php | 2 +- app/controllers/api/avatars.php | 2 +- app/controllers/api/databases.php | 2 +- app/controllers/api/functions.php | 2 +- app/controllers/api/messaging.php | 2 +- app/controllers/api/migrations.php | 2 +- app/controllers/api/project.php | 2 +- app/controllers/api/projects.php | 2 +- app/controllers/api/proxy.php | 2 +- app/controllers/api/storage.php | 2 +- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- app/controllers/api/vcs.php | 2 +- app/controllers/general.php | 2 +- app/controllers/mock.php | 2 +- app/controllers/shared/api.php | 2 +- app/http.php | 4 +- app/init.php | 8 ++-- app/realtime.php | 2 +- app/worker.php | 2 +- src/Appwrite/Migration/Migration.php | 6 +-- src/Appwrite/Migration/Version/V15.php | 2 +- src/Appwrite/Migration/Version/V16.php | 2 +- src/Appwrite/Migration/Version/V17.php | 2 +- src/Appwrite/Migration/Version/V18.php | 2 +- src/Appwrite/Migration/Version/V19.php | 2 +- src/Appwrite/Migration/Version/V20.php | 2 +- src/Appwrite/Platform/Tasks/Maintenance.php | 2 +- src/Appwrite/Platform/Tasks/Migrate.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleBase.php | 2 +- .../Platform/Tasks/ScheduleFunctions.php | 2 +- .../Platform/Tasks/ScheduleMessages.php | 2 +- src/Appwrite/Platform/Tasks/Specs.php | 2 +- src/Appwrite/Platform/Workers/Audits.php | 2 +- src/Appwrite/Platform/Workers/Builds.php | 2 +- .../Platform/Workers/Certificates.php | 2 +- src/Appwrite/Platform/Workers/Databases.php | 2 +- src/Appwrite/Platform/Workers/Deletes.php | 2 +- src/Appwrite/Platform/Workers/Functions.php | 2 +- src/Appwrite/Platform/Workers/Messaging.php | 2 +- src/Appwrite/Platform/Workers/Migrations.php | 2 +- src/Appwrite/Platform/Workers/Webhooks.php | 2 +- src/Appwrite/Utopia/Database/Database.php | 42 +++++++++++++++++++ .../Database/Validator/Queries/Base.php | 2 +- .../e2e/Services/Databases/DatabasesBase.php | 2 +- .../Databases/DatabasesCustomClientTest.php | 2 +- .../Databases/DatabasesCustomServerTest.php | 2 +- .../Services/GraphQL/DatabaseServerTest.php | 2 +- 50 files changed, 97 insertions(+), 55 deletions(-) create mode 100644 src/Appwrite/Utopia/Database/Database.php diff --git a/app/cli.php b/app/cli.php index 87bb711daa..4fb846e023 100644 --- a/app/cli.php +++ b/app/cli.php @@ -7,12 +7,12 @@ use Appwrite\Event\Certificate; use Appwrite\Event\Delete; use Appwrite\Event\Func; use Appwrite\Platform\Appwrite; +use Appwrite\Utopia\Database\Database; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\CLI; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; use Utopia\DSN\DSN; diff --git a/app/config/collections.php b/app/config/collections.php index 72d126e343..ecc1a7815c 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1,8 +1,8 @@ on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $reg try { $attempts++; $dbForConsole = $app->getResource('dbForConsole'); - /** @var Utopia\Database\Database $dbForConsole */ + /** @var Appwrite\Utopia\Database\Database $dbForConsole */ break; // leave the do-while if successful } catch (\Throwable $e) { Console::warning("Database not ready. Retrying connection ({$attempts})..."); diff --git a/app/init.php b/app/init.php index a86156c750..786e894fa8 100644 --- a/app/init.php +++ b/app/init.php @@ -40,6 +40,7 @@ use Appwrite\Network\Validator\Email; use Appwrite\Network\Validator\Origin; use Appwrite\OpenSSL\OpenSSL; use Appwrite\URL\URL as AppwriteURL; +use Appwrite\Utopia\Database\Database; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use Swoole\Database\PDOProxy; @@ -52,7 +53,6 @@ use Utopia\Config\Config; use Utopia\Database\Adapter\MariaDB; use Utopia\Database\Adapter\MySQL; use Utopia\Database\Adapter\SQL; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; @@ -1124,8 +1124,8 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons /** @var Appwrite\Utopia\Request $request */ /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Document $project */ - /** @var Utopia\Database\Database $dbForProject */ - /** @var Utopia\Database\Database $dbForConsole */ + /** @var Appwrite\Utopia\Database\Database $dbForProject */ + /** @var Appwrite\Utopia\Database\Database $dbForConsole */ /** @var string $mode */ Authorization::setDefaultStatus(true); @@ -1229,7 +1229,7 @@ App::setResource('user', function ($mode, $project, $console, $request, $respons App::setResource('project', function ($dbForConsole, $request, $console) { /** @var Appwrite\Utopia\Request $request */ - /** @var Utopia\Database\Database $dbForConsole */ + /** @var Appwrite\Utopia\Database\Database $dbForConsole */ /** @var Utopia\Database\Document $console */ $projectId = $request->getParam('project', $request->getHeader('x-appwrite-project', '')); diff --git a/app/realtime.php b/app/realtime.php index cde4327417..5a2fa7b55d 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -5,6 +5,7 @@ use Appwrite\Extend\Exception; use Appwrite\Extend\Exception as AppwriteException; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Network\Validator\Origin; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Request; use Appwrite\Utopia\Response; use Swoole\Http\Request as SwooleRequest; @@ -19,7 +20,6 @@ use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/app/worker.php b/app/worker.php index bca92c433f..7ac679a02a 100644 --- a/app/worker.php +++ b/app/worker.php @@ -15,13 +15,13 @@ use Appwrite\Event\Migration; use Appwrite\Event\Usage; use Appwrite\Event\UsageDump; use Appwrite\Platform\Appwrite; +use Appwrite\Utopia\Database\Database; use Swoole\Runtime; use Utopia\App; use Utopia\Cache\Adapter\Sharding; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Validator\Authorization; diff --git a/src/Appwrite/Migration/Migration.php b/src/Appwrite/Migration/Migration.php index 15c14daf51..9ccea5bdb6 100644 --- a/src/Appwrite/Migration/Migration.php +++ b/src/Appwrite/Migration/Migration.php @@ -2,11 +2,11 @@ namespace Appwrite\Migration; +use Appwrite\Utopia\Database\Database; use Exception; use Swoole\Runtime; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Query; @@ -293,7 +293,7 @@ abstract class Migration /** * Creates attribute from collections.php * - * @param \Utopia\Database\Database $database + * @param \Appwrite\Utopia\Database\Database $database * @param string $collectionId * @param string $attributeId * @return void @@ -350,7 +350,7 @@ abstract class Migration /** * Creates index from collections.php * - * @param \Utopia\Database\Database $database + * @param \Appwrite\Utopia\Database\Database $database * @param string $collectionId * @param string $indexId * @param string|null $from diff --git a/src/Appwrite/Migration/Version/V15.php b/src/Appwrite/Migration/Version/V15.php index ca20b6d7b3..756553b1ba 100644 --- a/src/Appwrite/Migration/Version/V15.php +++ b/src/Appwrite/Migration/Version/V15.php @@ -4,9 +4,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; use Appwrite\OpenSSL\OpenSSL; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; diff --git a/src/Appwrite/Migration/Version/V16.php b/src/Appwrite/Migration/Version/V16.php index 49f244598e..28a3369c58 100644 --- a/src/Appwrite/Migration/Version/V16.php +++ b/src/Appwrite/Migration/Version/V16.php @@ -4,9 +4,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; class V16 extends Migration diff --git a/src/Appwrite/Migration/Version/V17.php b/src/Appwrite/Migration/Version/V17.php index 96c890c65d..6c82c34aef 100644 --- a/src/Appwrite/Migration/Version/V17.php +++ b/src/Appwrite/Migration/Version/V17.php @@ -4,8 +4,8 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; class V17 extends Migration diff --git a/src/Appwrite/Migration/Version/V18.php b/src/Appwrite/Migration/Version/V18.php index ac4093aaca..429ac9aeab 100644 --- a/src/Appwrite/Migration/Version/V18.php +++ b/src/Appwrite/Migration/Version/V18.php @@ -3,8 +3,8 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/src/Appwrite/Migration/Version/V19.php b/src/Appwrite/Migration/Version/V19.php index bb887e40f7..0ecc9c9612 100644 --- a/src/Appwrite/Migration/Version/V19.php +++ b/src/Appwrite/Migration/Version/V19.php @@ -3,9 +3,9 @@ namespace Appwrite\Migration\Version; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; diff --git a/src/Appwrite/Migration/Version/V20.php b/src/Appwrite/Migration/Version/V20.php index 1a599d32f2..d89acb4980 100644 --- a/src/Appwrite/Migration/Version/V20.php +++ b/src/Appwrite/Migration/Version/V20.php @@ -4,11 +4,11 @@ namespace Appwrite\Migration\Version; use Appwrite\Auth\Auth; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Exception; use PDOException; use Throwable; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index cfbc4b200a..d3343f10fc 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -4,8 +4,8 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Certificate; use Appwrite\Event\Delete; +use Appwrite\Utopia\Database\Database; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Query; diff --git a/src/Appwrite/Platform/Tasks/Migrate.php b/src/Appwrite/Platform/Tasks/Migrate.php index 6e4fe38eb7..d0796c636a 100644 --- a/src/Appwrite/Platform/Tasks/Migrate.php +++ b/src/Appwrite/Platform/Tasks/Migrate.php @@ -3,10 +3,10 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Migration\Migration; +use Appwrite\Utopia\Database\Database; use Utopia\App; use Utopia\Cache\Cache; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Database\Validator\Authorization; diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index a50fbb2403..ea06109f48 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -2,9 +2,9 @@ namespace Appwrite\Platform\Tasks; +use Appwrite\Utopia\Database\Database; use Swoole\Timer; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception; diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index e2c278714f..f081f6ac0d 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -3,9 +3,9 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Func; +use Appwrite\Utopia\Database\Database; use Cron\CronExpression; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Pools\Group; diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 8e52973a0c..98c5c7a540 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -3,7 +3,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\Messaging; -use Utopia\Database\Database; +use Appwrite\Utopia\Database\Database; use Utopia\Pools\Group; class ScheduleMessages extends ScheduleBase diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 114e12ac85..945f718417 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -5,6 +5,7 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Specification\Format\OpenAPI3; use Appwrite\Specification\Format\Swagger2; use Appwrite\Specification\Specification; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response; use Exception; use Swoole\Http\Response as HttpResponse; @@ -14,7 +15,6 @@ use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; use Utopia\Database\Adapter\MySQL; -use Utopia\Database\Database; use Utopia\Platform\Action; use Utopia\Registry\Registry; use Utopia\Request; diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index 86ca59d3fd..69747c8c9b 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -2,10 +2,10 @@ namespace Appwrite\Platform\Workers; +use Appwrite\Utopia\Database\Database; use Exception; use Throwable; use Utopia\Audit\Audit; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Structure; diff --git a/src/Appwrite/Platform/Workers/Builds.php b/src/Appwrite/Platform/Workers/Builds.php index 8bb9dbb390..3ab17c45b1 100644 --- a/src/Appwrite/Platform/Workers/Builds.php +++ b/src/Appwrite/Platform/Workers/Builds.php @@ -6,6 +6,7 @@ use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Event\Usage; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Vcs\Comment; use Executor\Executor; @@ -13,7 +14,6 @@ use Swoole\Coroutine as Co; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Certificates.php b/src/Appwrite/Platform/Workers/Certificates.php index 1fbbd3b2ec..ca7179850b 100644 --- a/src/Appwrite/Platform/Workers/Certificates.php +++ b/src/Appwrite/Platform/Workers/Certificates.php @@ -8,12 +8,12 @@ use Appwrite\Event\Mail; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Network\Validator\CNAME; use Appwrite\Template\Template; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Rule; use Exception; use Throwable; use Utopia\App; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 56f5f012e8..9f32398c3d 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -4,10 +4,10 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Database\Database; use Exception; use Utopia\Audit\Audit; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; use Utopia\Database\Exception\Authorization; diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index d54f3f5079..e00a0c824c 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -4,6 +4,7 @@ namespace Appwrite\Platform\Workers; use Appwrite\Auth\Auth; use Appwrite\Extend\Exception; +use Appwrite\Utopia\Database\Database; use Executor\Executor; use Throwable; use Utopia\Abuse\Abuse; @@ -13,7 +14,6 @@ use Utopia\Cache\Adapter\Filesystem; use Utopia\Cache\Cache; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception as DatabaseException; diff --git a/src/Appwrite/Platform/Workers/Functions.php b/src/Appwrite/Platform/Workers/Functions.php index b071a79bfd..75a82f385d 100644 --- a/src/Appwrite/Platform/Workers/Functions.php +++ b/src/Appwrite/Platform/Workers/Functions.php @@ -6,12 +6,12 @@ use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Event\Usage; use Appwrite\Messaging\Adapter\Realtime; +use Appwrite\Utopia\Database\Database; use Appwrite\Utopia\Response\Model\Execution; use Exception; use Executor\Executor; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 6f642fabb7..72c81ad2a5 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -4,10 +4,10 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Usage; use Appwrite\Messaging\Status as MessageStatus; +use Appwrite\Utopia\Database\Database; use Swoole\Runtime; use Utopia\CLI\Console; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index 8e4aa5216d..04935b806f 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -6,9 +6,9 @@ use Appwrite\Event\Event; use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Permission; use Appwrite\Role; +use Appwrite\Utopia\Database\Database; use Exception; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; use Utopia\Database\Exception\Conflict; diff --git a/src/Appwrite/Platform/Workers/Webhooks.php b/src/Appwrite/Platform/Workers/Webhooks.php index d60946f709..de9d46147f 100644 --- a/src/Appwrite/Platform/Workers/Webhooks.php +++ b/src/Appwrite/Platform/Workers/Webhooks.php @@ -4,8 +4,8 @@ namespace Appwrite\Platform\Workers; use Appwrite\Event\Mail; use Appwrite\Template\Template; +use Appwrite\Utopia\Database\Database; use Exception; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; use Utopia\Logger\Log; diff --git a/src/Appwrite/Utopia/Database/Database.php b/src/Appwrite/Utopia/Database/Database.php new file mode 100644 index 0000000000..3e0a59b394 --- /dev/null +++ b/src/Appwrite/Utopia/Database/Database.php @@ -0,0 +1,42 @@ +getMethod() === Query::TYPE_SEARCH || $query->getMethod() === Query::TYPE_EQUAL) { + $attribute = $query->getAttribute(); + + if ($collectionCache === null) { + $collectionCache = $this->silent(fn () => $this->getCollection($collection)); + } + + $attributeMetadata = null; + foreach ($collectionCache->getAttribute('attributes', []) as $attributeDocument) { + if ($attributeDocument->getId() === $attribute) { + $attributeMetadata = $attributeDocument; + break; + } + } + + if ($attributeMetadata !== null) { + if ($attributeMetadata->getAttribute('array', false) === true) { + $query->setMethod(Query::TYPE_CONTAINS); + } + } + } + } + } catch (\Throwable $err) { + // Ignore error, to not do any harm + } + + return parent::find($collection, $queries); + } +} diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index a3555c08dd..1f3f0effda 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -2,8 +2,8 @@ namespace Appwrite\Utopia\Database\Validator\Queries; +use Appwrite\Utopia\Database\Database; use Utopia\Config\Config; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Validator\Queries; use Utopia\Database\Validator\Query\Cursor; diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 6f65552f1c..492253f74f 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -3,8 +3,8 @@ namespace Tests\E2E\Services\Databases; use Appwrite\Extend\Exception; +use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Helpers\ID; diff --git a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php index 8484996058..bff3c44d47 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomClientTest.php @@ -2,11 +2,11 @@ namespace Tests\E2E\Services\Databases; +use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideClient; -use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role; diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index 085d3ca01b..558443c249 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -3,11 +3,11 @@ namespace Tests\E2E\Services\Databases; use Appwrite\Extend\Exception as AppwriteException; +use Appwrite\Utopia\Database\Database; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Exception; use Utopia\Database\Helpers\ID; diff --git a/tests/e2e/Services/GraphQL/DatabaseServerTest.php b/tests/e2e/Services/GraphQL/DatabaseServerTest.php index 87006a1bea..ba0bec9549 100644 --- a/tests/e2e/Services/GraphQL/DatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/DatabaseServerTest.php @@ -2,12 +2,12 @@ namespace Tests\E2E\Services\GraphQL; +use Appwrite\Utopia\Database\Database; use Exception; use Tests\E2E\Client; use Tests\E2E\Scopes\ProjectCustom; use Tests\E2E\Scopes\Scope; use Tests\E2E\Scopes\SideServer; -use Utopia\Database\Database; use Utopia\Database\Helpers\ID; use Utopia\Database\Helpers\Permission; use Utopia\Database\Helpers\Role;