mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Query select
This commit is contained in:
@@ -6,13 +6,57 @@ use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Query;
|
||||
|
||||
//use Utopia\Database\Validator\Query\Filter;
|
||||
//use Utopia\Database\Validator\Query\Order;
|
||||
//use Utopia\Database\Validator\Query\Select;
|
||||
use Utopia\Database\QueryContext;
|
||||
|
||||
class Base extends Types
|
||||
{
|
||||
protected Document $collection;
|
||||
|
||||
protected array $types = [
|
||||
Query::TYPE_LIMIT,
|
||||
Query::TYPE_OFFSET,
|
||||
Query::TYPE_CURSOR_AFTER,
|
||||
Query::TYPE_CURSOR_BEFORE,
|
||||
Query::TYPE_ORDER_ASC,
|
||||
Query::TYPE_ORDER_DESC,
|
||||
Query::TYPE_ORDER_RANDOM,
|
||||
Query::TYPE_EQUAL,
|
||||
Query::TYPE_NOT_EQUAL,
|
||||
Query::TYPE_LESSER,
|
||||
Query::TYPE_LESSER_EQUAL,
|
||||
Query::TYPE_GREATER,
|
||||
Query::TYPE_GREATER_EQUAL,
|
||||
Query::TYPE_SEARCH,
|
||||
Query::TYPE_NOT_SEARCH,
|
||||
Query::TYPE_IS_NULL,
|
||||
Query::TYPE_IS_NOT_NULL,
|
||||
Query::TYPE_BETWEEN,
|
||||
Query::TYPE_NOT_BETWEEN,
|
||||
Query::TYPE_STARTS_WITH,
|
||||
Query::TYPE_NOT_STARTS_WITH,
|
||||
Query::TYPE_ENDS_WITH,
|
||||
Query::TYPE_NOT_ENDS_WITH,
|
||||
Query::TYPE_CONTAINS,
|
||||
Query::TYPE_NOT_CONTAINS,
|
||||
Query::TYPE_AND,
|
||||
Query::TYPE_OR,
|
||||
Query::TYPE_CROSSES,
|
||||
Query::TYPE_NOT_CROSSES,
|
||||
Query::TYPE_DISTANCE_EQUAL,
|
||||
Query::TYPE_DISTANCE_NOT_EQUAL,
|
||||
Query::TYPE_DISTANCE_GREATER_THAN,
|
||||
Query::TYPE_DISTANCE_LESS_THAN,
|
||||
Query::TYPE_INTERSECTS,
|
||||
Query::TYPE_NOT_INTERSECTS,
|
||||
Query::TYPE_OVERLAPS,
|
||||
Query::TYPE_NOT_OVERLAPS,
|
||||
Query::TYPE_TOUCHES,
|
||||
Query::TYPE_NOT_TOUCHES,
|
||||
Query::TYPE_VECTOR_DOT,
|
||||
Query::TYPE_VECTOR_COSINE,
|
||||
Query::TYPE_VECTOR_EUCLIDEAN
|
||||
];
|
||||
|
||||
/**
|
||||
* Expression constructor
|
||||
*
|
||||
@@ -22,51 +66,6 @@ class Base extends Types
|
||||
*/
|
||||
public function __construct(string $collection, array $allowedAttributes)
|
||||
{
|
||||
$types = [
|
||||
Query::TYPE_LIMIT,
|
||||
Query::TYPE_OFFSET,
|
||||
Query::TYPE_CURSOR_AFTER,
|
||||
Query::TYPE_CURSOR_BEFORE,
|
||||
Query::TYPE_ORDER_ASC,
|
||||
Query::TYPE_ORDER_DESC,
|
||||
Query::TYPE_ORDER_RANDOM,
|
||||
Query::TYPE_EQUAL,
|
||||
Query::TYPE_NOT_EQUAL,
|
||||
Query::TYPE_LESSER,
|
||||
Query::TYPE_LESSER_EQUAL,
|
||||
Query::TYPE_GREATER,
|
||||
Query::TYPE_GREATER_EQUAL,
|
||||
Query::TYPE_SEARCH,
|
||||
Query::TYPE_NOT_SEARCH,
|
||||
Query::TYPE_IS_NULL,
|
||||
Query::TYPE_IS_NOT_NULL,
|
||||
Query::TYPE_BETWEEN,
|
||||
Query::TYPE_NOT_BETWEEN,
|
||||
Query::TYPE_STARTS_WITH,
|
||||
Query::TYPE_NOT_STARTS_WITH,
|
||||
Query::TYPE_ENDS_WITH,
|
||||
Query::TYPE_NOT_ENDS_WITH,
|
||||
Query::TYPE_CONTAINS,
|
||||
Query::TYPE_NOT_CONTAINS,
|
||||
Query::TYPE_AND,
|
||||
Query::TYPE_OR,
|
||||
Query::TYPE_CROSSES,
|
||||
Query::TYPE_NOT_CROSSES,
|
||||
Query::TYPE_DISTANCE_EQUAL,
|
||||
Query::TYPE_DISTANCE_NOT_EQUAL,
|
||||
Query::TYPE_DISTANCE_GREATER_THAN,
|
||||
Query::TYPE_DISTANCE_LESS_THAN,
|
||||
Query::TYPE_INTERSECTS,
|
||||
Query::TYPE_NOT_INTERSECTS,
|
||||
Query::TYPE_OVERLAPS,
|
||||
Query::TYPE_NOT_OVERLAPS,
|
||||
Query::TYPE_TOUCHES,
|
||||
Query::TYPE_NOT_TOUCHES,
|
||||
Query::TYPE_VECTOR_DOT,
|
||||
Query::TYPE_VECTOR_COSINE,
|
||||
Query::TYPE_VECTOR_EUCLIDEAN
|
||||
];
|
||||
|
||||
$config = Config::getParam('collections', []);
|
||||
|
||||
$collections = \array_merge(
|
||||
@@ -79,26 +78,23 @@ class Base extends Types
|
||||
|
||||
$collection = $collections[$collection];
|
||||
|
||||
$allowedAttributesLookup = [];
|
||||
foreach ($allowedAttributes as $attribute) {
|
||||
$allowedAttributesLookup[$attribute] = true;
|
||||
}
|
||||
$this->collection = new Document;
|
||||
$this->collection->setAttribute('$id', $collection['$id']);
|
||||
|
||||
$allAttributes = [];
|
||||
$attributes = [];
|
||||
foreach ($collection['attributes'] as $attribute) {
|
||||
$key = $attribute['$id'];
|
||||
|
||||
$attributeDocument = new Document([
|
||||
'key' => $key,
|
||||
$attr = new Document([
|
||||
'key' => $attribute['$id'],
|
||||
'type' => $attribute['type'],
|
||||
'array' => $attribute['array'],
|
||||
]);
|
||||
|
||||
$allAttributes[] = $attributeDocument;
|
||||
$this->collection->setAttribute('attributes', $attr, Document::SET_TYPE_APPEND);
|
||||
|
||||
if (isset($allowedAttributesLookup[$key])) {
|
||||
$attributes[] = $attributeDocument;
|
||||
if (in_array($attribute['$id'], $allowedAttributes)){
|
||||
/**
|
||||
* todo find a way to Filter only allowed attribute, while selecting is ok
|
||||
*/
|
||||
//$this->collection->setAttribute('attributes', $attr, Document::SET_TYPE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,15 +122,17 @@ class Base extends Types
|
||||
];
|
||||
|
||||
foreach ($internalAttributes as $attribute) {
|
||||
$attributes[] = $attribute;
|
||||
$allAttributes[] = $attribute;
|
||||
$this->collection->setAttribute('attributes', $attribute, Document::SET_TYPE_APPEND);
|
||||
}
|
||||
|
||||
if ($this->isSelectQueryAllowed()) {
|
||||
$types[] = Query::TYPE_SELECT;
|
||||
$this->types[] = Query::TYPE_SELECT;
|
||||
}
|
||||
|
||||
parent::__construct($types);
|
||||
$context = new QueryContext;
|
||||
$context->add($this->collection);
|
||||
|
||||
parent::__construct($this->types, $context);
|
||||
}
|
||||
|
||||
public function isSelectQueryAllowed(): bool
|
||||
|
||||
@@ -22,12 +22,23 @@ class Types extends Validator
|
||||
*/
|
||||
protected array $queries;
|
||||
|
||||
/**
|
||||
* @var QueryContext
|
||||
*/
|
||||
protected ?QueryContext $context = null;
|
||||
|
||||
/**
|
||||
* @param array<string> $types
|
||||
*/
|
||||
public function __construct(array $types = [])
|
||||
public function __construct(array $types = [], ?QueryContext $context = null)
|
||||
{
|
||||
$this->types = $types;
|
||||
|
||||
if ($context === null) {
|
||||
$context = new QueryContext();
|
||||
}
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,9 +82,7 @@ class Types extends Validator
|
||||
}
|
||||
}
|
||||
|
||||
$context = new QueryContext();
|
||||
|
||||
$validator = new DocumentsValidator($context, Database::VAR_INTEGER);
|
||||
$validator = new DocumentsValidator($this->context, Database::VAR_INTEGER);
|
||||
|
||||
if (!$validator->isValid($value)) {
|
||||
throw new \Exception($validator->getDescription());
|
||||
@@ -84,7 +93,7 @@ class Types extends Validator
|
||||
var_dump($e->getFile());
|
||||
var_dump($e->getLine());
|
||||
|
||||
$this->message = 'Invalid query: ' . $e->getMessage();
|
||||
$this->message = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), [
|
||||
'queries' => [Query::select(['key'])->toString()],
|
||||
'queries' => [Query::select('key')->toString()],
|
||||
]);
|
||||
$this->assertEquals(Exception::GENERAL_ARGUMENT_INVALID, $response['body']['type']);
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
@@ -1565,7 +1565,7 @@ trait DatabasesBase
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['key'])->toString(),
|
||||
Query::select('key')->toString(),
|
||||
],
|
||||
]);
|
||||
$this->assertEquals(Exception::GENERAL_ARGUMENT_INVALID, $response['body']['type']);
|
||||
@@ -1965,7 +1965,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library', ['library1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -2003,7 +2004,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library', ['library1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -2041,7 +2043,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString()
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
],
|
||||
]);
|
||||
$this->assertEquals(2, $documents['body']['total']);
|
||||
@@ -2200,7 +2203,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString()
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
],
|
||||
]);
|
||||
$this->assertGreaterThanOrEqual(1, $documents['body']['total']);
|
||||
@@ -2411,7 +2415,9 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['title', 'releaseYear', '$id'])->toString(),
|
||||
Query::select('title')->toString(),
|
||||
Query::select('releaseYear')->toString(),
|
||||
Query::select('$id')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5111,7 +5117,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library', ['library1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -5125,7 +5132,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['library.*'])->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library.libraryName', ['Library 1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -5283,7 +5290,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'libraries.*'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('libraries.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5297,7 +5305,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['person_one_to_many.$id'])->toString()
|
||||
Query::select('person_one_to_many.$id')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5451,7 +5459,9 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'artist.name', 'artist.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('artist.name')->toString(),
|
||||
Query::select('artist.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5467,7 +5477,10 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'albums.$id', 'albums.name', 'albums.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('albums.$id')->toString(),
|
||||
Query::select('albums.name')->toString(),
|
||||
Query::select('albums.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5612,7 +5625,9 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'players.name', 'players.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('players.name')->toString(),
|
||||
Query::select('players.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5630,7 +5645,10 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'sports.$id', 'sports.name', 'sports.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('sports.$id')->toString(),
|
||||
Query::select('sports.name')->toString(),
|
||||
Query::select('sports.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5660,7 +5678,8 @@ trait DatabasesBase
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::isNotNull('$id')->toString(),
|
||||
Query::select(['*', 'libraries.*'])->toString(),
|
||||
Query::select('*')->toString(),
|
||||
Query::select('libraries.*')->toString(),
|
||||
Query::startsWith('fullName', 'Stevie')->toString(),
|
||||
Query::endsWith('fullName', 'Wonder')->toString(),
|
||||
Query::between('$createdAt', '1975-12-06', '2050-12-01')->toString(),
|
||||
@@ -5680,7 +5699,7 @@ trait DatabasesBase
|
||||
'queries' => [
|
||||
Query::isNotNull('$id')->toString(),
|
||||
Query::isNull('fullName')->toString(),
|
||||
Query::select(['fullName'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5717,7 +5736,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['libraries.*', '$id'])->toString(),
|
||||
Query::select('libraries.*')->toString(),
|
||||
Query::select('$id')->toString(),
|
||||
],
|
||||
]);
|
||||
$document = $response['body']['documents'][0];
|
||||
@@ -5731,7 +5751,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', '$id'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('$id')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5861,7 +5882,8 @@ trait DatabasesBase
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'queries' => [
|
||||
Query::select(['first_name', 'last_name'])->toString(),
|
||||
Query::select('first_name')->toString(),
|
||||
Query::select('last_name')->toString(),
|
||||
Query::or([
|
||||
Query::equal('first_name', ['Donald']),
|
||||
Query::equal('last_name', ['Bush'])
|
||||
@@ -7342,7 +7364,10 @@ trait DatabasesBase
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [Query::select(['name', 'pointAttr'])->toString()]
|
||||
'queries' => [
|
||||
Query::select('name')->toString(),
|
||||
Query::select('pointAttr')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
@@ -7397,7 +7422,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['name', 'pointAttr'])->toString(),
|
||||
Query::select('name')->toString(),
|
||||
Query::select('pointAttr')->toString(),
|
||||
Query::orderAsc('name')->toString(),
|
||||
Query::limit(1)->toString()
|
||||
]
|
||||
@@ -7546,7 +7572,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['name', 'location.coordinates'])->toString()
|
||||
Query::select('name')->toString(),
|
||||
Query::select('location.coordinates')->toString()
|
||||
]
|
||||
]);
|
||||
$this->assertEquals(200, $fetched['headers']['status-code']);
|
||||
@@ -7680,7 +7707,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['point', 'person.$id'])->toString()
|
||||
Query::select('point')->toString(),
|
||||
Query::select('person.$id')->toString()
|
||||
]
|
||||
]);
|
||||
$this->assertEquals(200, $visitDoc['headers']['status-code']);
|
||||
@@ -7805,7 +7833,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['stores.$id'])->toString()
|
||||
Query::select('stores.$id')->toString()
|
||||
]
|
||||
]);
|
||||
$this->assertEquals(200, $city['headers']['status-code']);
|
||||
@@ -7930,7 +7958,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['drivers.$id'])->toString()
|
||||
Query::select('drivers.$id')->toString()
|
||||
]
|
||||
]);
|
||||
$this->assertEquals(200, $zone['headers']['status-code']);
|
||||
|
||||
@@ -3830,7 +3830,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -3944,7 +3944,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -4058,7 +4058,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -4073,7 +4073,8 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'level1.*'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('level1.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -4191,7 +4192,8 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'level1.*'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('level1.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
@@ -400,7 +400,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), [
|
||||
'queries' => [Query::select(['key'])->toString()],
|
||||
'queries' => [Query::select('key')->toString()],
|
||||
]);
|
||||
$this->assertEquals(Exception::GENERAL_ARGUMENT_INVALID, $response['body']['type']);
|
||||
$this->assertEquals(400, $response['headers']['status-code']);
|
||||
@@ -1523,7 +1523,7 @@ trait DatabasesBase
|
||||
'x-appwrite-key' => $this->getProject()['apiKey'],
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['key'])->toString(),
|
||||
Query::select('key')->toString(),
|
||||
],
|
||||
]);
|
||||
$this->assertEquals(Exception::GENERAL_ARGUMENT_INVALID, $response['body']['type']);
|
||||
@@ -1940,7 +1940,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library', ['library1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -1978,7 +1979,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library', ['library1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -2016,7 +2018,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString()
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString()
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -2176,7 +2179,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString()
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString()
|
||||
],
|
||||
]);
|
||||
$this->assertGreaterThanOrEqual(1, $rows['body']['total']);
|
||||
@@ -2339,7 +2343,9 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['title', 'releaseYear', '$id'])->toString(),
|
||||
Query::select('title')->toString(),
|
||||
Query::select('releaseYear')->toString(),
|
||||
Query::select('$id')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5027,7 +5033,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', 'library.*'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library', ['library1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -5041,7 +5048,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['library.*'])->toString(),
|
||||
Query::select('library.*')->toString(),
|
||||
Query::equal('library.libraryName', ['Library 1'])->toString(),
|
||||
],
|
||||
]);
|
||||
@@ -5199,7 +5206,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'libraries.*'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('libraries.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5213,7 +5221,7 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['person_one_to_many.$id'])->toString()
|
||||
Query::select('person_one_to_many.$id')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5367,7 +5375,9 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'artist.name', 'artist.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('artist.name')->toString(),
|
||||
Query::select('artist.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5383,7 +5393,10 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'albums.$id', 'albums.name', 'albums.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('albums.$id')->toString(),
|
||||
Query::select('albums.name')->toString(),
|
||||
Query::select('albums.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5528,7 +5541,9 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'players.name', 'players.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('players.name')->toString(),
|
||||
Query::select('players.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5546,7 +5561,10 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'sports.$id', 'sports.name', 'sports.$permissions'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('sports.$id')->toString(),
|
||||
Query::select('sports.name')->toString(),
|
||||
Query::select('sports.$permissions')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -5576,7 +5594,8 @@ trait DatabasesBase
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::isNotNull('$id')->toString(),
|
||||
Query::select(['*', 'libraries.*'])->toString(),
|
||||
Query::select('*')->toString(),
|
||||
Query::select('libraries.*')->toString(),
|
||||
Query::startsWith('fullName', 'Stevie')->toString(),
|
||||
Query::endsWith('fullName', 'Wonder')->toString(),
|
||||
Query::between('$createdAt', '1975-12-06', '2050-12-01')->toString(),
|
||||
@@ -5596,7 +5615,7 @@ trait DatabasesBase
|
||||
'queries' => [
|
||||
Query::isNotNull('$id')->toString(),
|
||||
Query::isNull('fullName')->toString(),
|
||||
Query::select(['fullName'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5619,7 +5638,7 @@ trait DatabasesBase
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::equal('fullName', ['Stevie Wonder'])->toString(),
|
||||
Query::select(['fullName'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5633,7 +5652,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['libraries.*', '$id'])->toString(),
|
||||
Query::select('libraries.*')->toString(),
|
||||
Query::select('$id')->toString(),
|
||||
],
|
||||
]);
|
||||
$row = $response['body']['rows'][0];
|
||||
@@ -5647,7 +5667,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['fullName', '$id'])->toString(),
|
||||
Query::select('fullName')->toString(),
|
||||
Query::select('$id')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -5777,7 +5798,8 @@ trait DatabasesBase
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'queries' => [
|
||||
Query::select(['first_name', 'last_name'])->toString(),
|
||||
Query::select('first_name')->toString(),
|
||||
Query::select('last_name')->toString(),
|
||||
Query::or([
|
||||
Query::equal('first_name', ['Donald']),
|
||||
Query::equal('last_name', ['Bush'])
|
||||
@@ -5914,7 +5936,8 @@ trait DatabasesBase
|
||||
], $this->getHeaders()),
|
||||
[
|
||||
'queries' => [
|
||||
Query::select(['title', 'genre'])->toString(),
|
||||
Query::select('title')->toString(),
|
||||
Query::select('genre')->toString(),
|
||||
Query::notContains('title', ['Spider'])->toString(),
|
||||
Query::limit(999)->toString(),
|
||||
Query::offset(0)->toString()
|
||||
@@ -8791,7 +8814,10 @@ trait DatabasesBase
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [Query::select(['name', 'pointAttr'])->toString()]
|
||||
'queries' => [
|
||||
Query::select('name')->toString(),
|
||||
Query::select('pointAttr')->toString(),
|
||||
]
|
||||
]);
|
||||
$this->assertEquals(200, $response['headers']['status-code']);
|
||||
$this->assertCount(3, $response['body']['rows']);
|
||||
@@ -8841,7 +8867,8 @@ trait DatabasesBase
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), [
|
||||
'queries' => [
|
||||
Query::select(['name', 'pointAttr'])->toString(),
|
||||
Query::select('name')->toString(),
|
||||
Query::select('pointAttr')->toString(),
|
||||
Query::orderAsc('name')->toString(),
|
||||
Query::limit(1)->toString()
|
||||
]
|
||||
|
||||
@@ -3759,7 +3759,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -3873,7 +3873,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -3987,7 +3987,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -4002,7 +4002,8 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'level1.*'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('level1.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -4105,7 +4106,7 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['new_level_2.*'])->toString()
|
||||
Query::select('new_level_2.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
@@ -4120,7 +4121,8 @@ class DatabasesCustomServerTest extends Scope
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]), [
|
||||
'queries' => [
|
||||
Query::select(['*', 'level1.*'])->toString()
|
||||
Query::select('*')->toString(),
|
||||
Query::select('level1.*')->toString()
|
||||
]
|
||||
]);
|
||||
|
||||
|
||||
@@ -873,7 +873,7 @@ class FunctionsCustomServerTest extends Scope
|
||||
|
||||
$deployments = $this->listDeployments($functionId, [
|
||||
'queries' => [
|
||||
Query::select(['status'])->toString(),
|
||||
Query::select('status')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -886,7 +886,7 @@ class FunctionsCustomServerTest extends Scope
|
||||
// Extra select query check, for attribute not allowed by filter queries
|
||||
$deployments = $this->listDeployments($functionId, [
|
||||
'queries' => [
|
||||
Query::select(['buildLogs'])->toString(),
|
||||
Query::select('buildLogs')->toString(),
|
||||
],
|
||||
]);
|
||||
$this->assertEquals($deployments['headers']['status-code'], 200);
|
||||
|
||||
@@ -1058,7 +1058,7 @@ class SitesCustomServerTest extends Scope
|
||||
|
||||
$deployments = $this->listDeployments($siteId, [
|
||||
'queries' => [
|
||||
Query::select(['status'])->toString(),
|
||||
Query::select('status')->toString(),
|
||||
],
|
||||
]);
|
||||
|
||||
@@ -1071,7 +1071,7 @@ class SitesCustomServerTest extends Scope
|
||||
// Extra select query check, for attribute not allowed by filter queries
|
||||
$deployments = $this->listDeployments($siteId, [
|
||||
'queries' => [
|
||||
Query::select(['buildLogs'])->toString(),
|
||||
Query::select('buildLogs')->toString(),
|
||||
],
|
||||
]);
|
||||
$this->assertEquals($deployments['headers']['status-code'], 200);
|
||||
|
||||
Reference in New Issue
Block a user