From 5463e62a6e73457800088a67d4d9c611603d32e1 Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 18 May 2022 04:36:24 +0400 Subject: [PATCH] feat: remove redundant order attributes validation --- app/config/platforms.php | 2 +- app/controllers/api/database.php | 18 +++++------------- composer.json | 2 +- composer.lock | 16 ++++++++-------- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/app/config/platforms.php b/app/config/platforms.php index fd630f536d..53d64c34e4 100644 --- a/app/config/platforms.php +++ b/app/config/platforms.php @@ -116,7 +116,7 @@ return [ [ 'key' => 'android', 'name' => 'Android', - 'version' => '0.6.0', + 'version' => '0.6.1', 'url' => 'https://github.com/appwrite/sdk-for-android', 'package' => 'https://search.maven.org/artifact/io.appwrite/sdk-for-android', 'enabled' => true, diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index ae24466da1..d002f95e07 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -19,7 +19,6 @@ use Utopia\Database\Validator\Authorization; use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\QueryValidator; -use Utopia\Database\Validator\OrderAttributes; use Utopia\Database\Validator\Structure; use Utopia\Database\Validator\UID; use Utopia\Database\Exception\Authorization as AuthorizationException; @@ -32,7 +31,7 @@ use Appwrite\Network\Validator\IP; use Appwrite\Network\Validator\URL; use Appwrite\Utopia\Database\Validator\CustomId; use Appwrite\Utopia\Database\Validator\Queries as QueriesValidator; -use Appwrite\Utopia\Database\Validator\OrderAttributes as OrderAttributesValidator; +use Appwrite\Utopia\Database\Validator\OrderAttributes; use Appwrite\Utopia\Response; use Appwrite\Detector\Detector; use Appwrite\Event\Audit as EventAudit; @@ -1776,20 +1775,13 @@ App::get('/v1/database/collections/:collectionId/documents') if(!empty($orderAttributes)) { $validator = new OrderAttributes($collection->getAttribute('attributes', []), $collection->getAttribute('indexes', []), true); if (!$validator->isValid($orderAttributes)) { - throw new Exception($validator->getDescription(), 400); - } - } - - if (!empty($queries)) { - $validator = new QueriesValidator(new QueryValidator($collection->getAttribute('attributes', [])), $collection->getAttribute('indexes', []), true); - if (!$validator->isValid($queries)) { throw new Exception($validator->getDescription(), 400, Exception::GENERAL_QUERY_INVALID); } } - - if(!empty($orderAttributes)) { - $validator = new OrderAttributesValidator($collection->getAttribute('attributes', []), $collection->getAttribute('indexes', []), true); - if (!$validator->isValid($orderAttributes)) { + + if (!empty($queries)) { + $validator = new QueriesValidator(new QueryValidator($collection->getAttribute('attributes', [])), $collection->getAttribute('indexes', []), true); + if (!$validator->isValid($queries)) { throw new Exception($validator->getDescription(), 400, Exception::GENERAL_QUERY_INVALID); } } diff --git a/composer.json b/composer.json index 4baf04043a..1cd1236d0f 100644 --- a/composer.json +++ b/composer.json @@ -71,7 +71,7 @@ } ], "require-dev": { - "appwrite/sdk-generator": "0.18.4", + "appwrite/sdk-generator": "0.18.6", "phpunit/phpunit": "9.5.20", "swoole/ide-helper": "4.8.9", "textalk/websocket": "1.5.7", diff --git a/composer.lock b/composer.lock index b946b34282..69aadee3ae 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": "ae4e8cc9efbd28d8c2536e378c9e7ead", + "content-hash": "69e0c12a4c4b22cf17727f5b8833b1ac", "packages": [ { "name": "adhocore/jwt", @@ -3075,16 +3075,16 @@ }, { "name": "appwrite/sdk-generator", - "version": "0.18.4", + "version": "0.18.6", "source": { "type": "git", "url": "https://github.com/appwrite/sdk-generator.git", - "reference": "841281fab95c774d5aa96f5bf9bd0dabf9f96e8d" + "reference": "c0914d9f4047fd7b86112c289d98e9161cf9d0b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/841281fab95c774d5aa96f5bf9bd0dabf9f96e8d", - "reference": "841281fab95c774d5aa96f5bf9bd0dabf9f96e8d", + "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/c0914d9f4047fd7b86112c289d98e9161cf9d0b0", + "reference": "c0914d9f4047fd7b86112c289d98e9161cf9d0b0", "shasum": "" }, "require": { @@ -3119,9 +3119,9 @@ "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "support": { "issues": "https://github.com/appwrite/sdk-generator/issues", - "source": "https://github.com/appwrite/sdk-generator/tree/0.18.4" + "source": "https://github.com/appwrite/sdk-generator/tree/0.18.6" }, - "time": "2022-05-17T12:16:09+00:00" + "time": "2022-05-17T15:09:23+00:00" }, { "name": "composer/pcre", @@ -6576,5 +6576,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.1.0" + "plugin-api-version": "2.3.0" }