1
0
Fork 0
mirror of synced 2024-07-05 22:51:24 +12:00

Merge pull request #3235 from appwrite/fix-database-query

feat: remove redundant order attributes validation
This commit is contained in:
Torsten Dittmann 2022-05-18 15:25:23 +02:00 committed by GitHub
commit 31b243996e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 23 deletions

View file

@ -116,7 +116,7 @@ return [
[ [
'key' => 'android', 'key' => 'android',
'name' => 'Android', 'name' => 'Android',
'version' => '0.6.0', 'version' => '0.6.1',
'url' => 'https://github.com/appwrite/sdk-for-android', 'url' => 'https://github.com/appwrite/sdk-for-android',
'package' => 'https://search.maven.org/artifact/io.appwrite/sdk-for-android', 'package' => 'https://search.maven.org/artifact/io.appwrite/sdk-for-android',
'enabled' => true, 'enabled' => true,

View file

@ -19,7 +19,6 @@ use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Key; use Utopia\Database\Validator\Key;
use Utopia\Database\Validator\Permissions; use Utopia\Database\Validator\Permissions;
use Utopia\Database\Validator\QueryValidator; use Utopia\Database\Validator\QueryValidator;
use Utopia\Database\Validator\OrderAttributes;
use Utopia\Database\Validator\Structure; use Utopia\Database\Validator\Structure;
use Utopia\Database\Validator\UID; use Utopia\Database\Validator\UID;
use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Authorization as AuthorizationException;
@ -32,7 +31,7 @@ use Appwrite\Network\Validator\IP;
use Appwrite\Network\Validator\URL; use Appwrite\Network\Validator\URL;
use Appwrite\Utopia\Database\Validator\CustomId; use Appwrite\Utopia\Database\Validator\CustomId;
use Appwrite\Utopia\Database\Validator\Queries as QueriesValidator; 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\Utopia\Response;
use Appwrite\Detector\Detector; use Appwrite\Detector\Detector;
use Appwrite\Event\Audit as EventAudit; use Appwrite\Event\Audit as EventAudit;
@ -1776,20 +1775,13 @@ App::get('/v1/database/collections/:collectionId/documents')
if(!empty($orderAttributes)) { if(!empty($orderAttributes)) {
$validator = new OrderAttributes($collection->getAttribute('attributes', []), $collection->getAttribute('indexes', []), true); $validator = new OrderAttributes($collection->getAttribute('attributes', []), $collection->getAttribute('indexes', []), true);
if (!$validator->isValid($orderAttributes)) { 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); throw new Exception($validator->getDescription(), 400, Exception::GENERAL_QUERY_INVALID);
} }
} }
if(!empty($orderAttributes)) { if (!empty($queries)) {
$validator = new OrderAttributesValidator($collection->getAttribute('attributes', []), $collection->getAttribute('indexes', []), true); $validator = new QueriesValidator(new QueryValidator($collection->getAttribute('attributes', [])), $collection->getAttribute('indexes', []), true);
if (!$validator->isValid($orderAttributes)) { if (!$validator->isValid($queries)) {
throw new Exception($validator->getDescription(), 400, Exception::GENERAL_QUERY_INVALID); throw new Exception($validator->getDescription(), 400, Exception::GENERAL_QUERY_INVALID);
} }
} }

View file

@ -71,7 +71,7 @@
} }
], ],
"require-dev": { "require-dev": {
"appwrite/sdk-generator": "0.18.4", "appwrite/sdk-generator": "0.18.6",
"phpunit/phpunit": "9.5.20", "phpunit/phpunit": "9.5.20",
"swoole/ide-helper": "4.8.9", "swoole/ide-helper": "4.8.9",
"textalk/websocket": "1.5.7", "textalk/websocket": "1.5.7",

16
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ae4e8cc9efbd28d8c2536e378c9e7ead", "content-hash": "69e0c12a4c4b22cf17727f5b8833b1ac",
"packages": [ "packages": [
{ {
"name": "adhocore/jwt", "name": "adhocore/jwt",
@ -3075,16 +3075,16 @@
}, },
{ {
"name": "appwrite/sdk-generator", "name": "appwrite/sdk-generator",
"version": "0.18.4", "version": "0.18.6",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/appwrite/sdk-generator.git", "url": "https://github.com/appwrite/sdk-generator.git",
"reference": "841281fab95c774d5aa96f5bf9bd0dabf9f96e8d" "reference": "c0914d9f4047fd7b86112c289d98e9161cf9d0b0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/841281fab95c774d5aa96f5bf9bd0dabf9f96e8d", "url": "https://api.github.com/repos/appwrite/sdk-generator/zipball/c0914d9f4047fd7b86112c289d98e9161cf9d0b0",
"reference": "841281fab95c774d5aa96f5bf9bd0dabf9f96e8d", "reference": "c0914d9f4047fd7b86112c289d98e9161cf9d0b0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3119,9 +3119,9 @@
"description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms", "description": "Appwrite PHP library for generating API SDKs for multiple programming languages and platforms",
"support": { "support": {
"issues": "https://github.com/appwrite/sdk-generator/issues", "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", "name": "composer/pcre",
@ -6576,5 +6576,5 @@
"platform-overrides": { "platform-overrides": {
"php": "8.0" "php": "8.0"
}, },
"plugin-api-version": "2.1.0" "plugin-api-version": "2.3.0"
} }