mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Disable index array
This commit is contained in:
@@ -2958,6 +2958,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes')
|
||||
$collection->getAttribute('attributes'),
|
||||
$dbForProject->getAdapter()->getMaxIndexLength(),
|
||||
$dbForProject->getAdapter()->getInternalIndexesKeys(),
|
||||
$dbForProject->getAdapter()->getSupportForIndexArray(),
|
||||
);
|
||||
|
||||
if (!$validator->isValid($index)) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
"utopia-php/cache": "0.13.*",
|
||||
"utopia-php/cli": "0.15.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "0.71.*",
|
||||
"utopia-php/database": "dev-validate-create-index-array as 0.71.10",
|
||||
"utopia-php/detector": "0.1.*",
|
||||
"utopia-php/domains": "0.8.*",
|
||||
"utopia-php/dsn": "0.2.1",
|
||||
|
||||
Generated
+18
-9
@@ -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": "f53e1ccd394581428d9efcb53b46d479",
|
||||
"content-hash": "b7f645a2dfd3313b7202189c133ea954",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
@@ -3493,16 +3493,16 @@
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "0.71.10",
|
||||
"version": "dev-validate-create-index-array",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "83278d663f9c63c25a11d9e71c7922da7ec48636"
|
||||
"reference": "9e2895b92cb094436973d5f8f30d75014bf03ae6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/83278d663f9c63c25a11d9e71c7922da7ec48636",
|
||||
"reference": "83278d663f9c63c25a11d9e71c7922da7ec48636",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/9e2895b92cb094436973d5f8f30d75014bf03ae6",
|
||||
"reference": "9e2895b92cb094436973d5f8f30d75014bf03ae6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -3543,9 +3543,9 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.71.10"
|
||||
"source": "https://github.com/utopia-php/database/tree/validate-create-index-array"
|
||||
},
|
||||
"time": "2025-07-18T00:05:55+00:00"
|
||||
"time": "2025-07-20T08:28:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/detector",
|
||||
@@ -8237,9 +8237,18 @@
|
||||
"time": "2024-03-07T20:33:40+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
"aliases": [
|
||||
{
|
||||
"package": "utopia-php/database",
|
||||
"version": "dev-validate-create-index-array",
|
||||
"alias": "0.71.10",
|
||||
"alias_normalized": "0.71.10.0"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {},
|
||||
"stability-flags": {
|
||||
"utopia-php/database": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
|
||||
@@ -12,6 +12,7 @@ use Utopia\Database\Helpers\Permission;
|
||||
use Utopia\Database\Helpers\Role;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Database\Validator\Datetime as DatetimeValidator;
|
||||
use Utopia\System\System;
|
||||
|
||||
trait DatabasesBase
|
||||
{
|
||||
@@ -1344,7 +1345,8 @@ trait DatabasesBase
|
||||
'attributes' => ['actors'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(202, $actorsArray['headers']['status-code']);
|
||||
$this->assertEquals(400, $actorsArray['headers']['status-code']);
|
||||
$this->assertEquals('Indexing an array attribute is temporarily disabled', $actorsArray['body']['message']);
|
||||
|
||||
$twoLevelsArray = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/indexes', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
@@ -1357,9 +1359,10 @@ trait DatabasesBase
|
||||
'orders' => ['DESC', 'DESC'],
|
||||
]);
|
||||
|
||||
$this->assertEquals(202, $twoLevelsArray['headers']['status-code']);
|
||||
$this->assertEquals('DESC', $twoLevelsArray['body']['orders'][0]);
|
||||
$this->assertEquals(null, $twoLevelsArray['body']['orders'][1]); // Overwrite by API (array)
|
||||
$this->assertEquals(400, $twoLevelsArray['headers']['status-code']);
|
||||
$this->assertEquals('Indexing an array attribute is temporarily disabled', $twoLevelsArray['body']['message']);
|
||||
//$this->assertEquals('DESC', $twoLevelsArray['body']['orders'][0]);
|
||||
//$this->assertEquals(null, $twoLevelsArray['body']['orders'][1]); // Overwrite by API (array)
|
||||
|
||||
$unknown = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/indexes', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
@@ -1384,7 +1387,8 @@ trait DatabasesBase
|
||||
'attributes' => ['integers'], // array attribute
|
||||
'orders' => ['DESC'], // Check order is removed in API
|
||||
]);
|
||||
$this->assertEquals(202, $index1['headers']['status-code']);
|
||||
$this->assertEquals(400, $index1['headers']['status-code']);
|
||||
$this->assertEquals('Indexing an array attribute is temporarily disabled', $index1['body']['message']);
|
||||
|
||||
$index2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/indexes', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
@@ -1395,7 +1399,8 @@ trait DatabasesBase
|
||||
'type' => 'key',
|
||||
'attributes' => ['integers'], // array attribute
|
||||
]);
|
||||
$this->assertEquals(202, $index2['headers']['status-code']);
|
||||
$this->assertEquals(400, $index2['headers']['status-code']);
|
||||
$this->assertEquals('Indexing an array attribute is temporarily disabled', $index2['body']['message']);
|
||||
|
||||
/**
|
||||
* Create Indexes by worker
|
||||
@@ -1409,7 +1414,7 @@ trait DatabasesBase
|
||||
]), []);
|
||||
|
||||
$this->assertIsArray($movies['body']['indexes']);
|
||||
$this->assertCount(8, $movies['body']['indexes']);
|
||||
$this->assertCount(4, $movies['body']['indexes']);
|
||||
$this->assertEquals($titleIndex['body']['key'], $movies['body']['indexes'][0]['key']);
|
||||
$this->assertEquals($releaseYearIndex['body']['key'], $movies['body']['indexes'][1]['key']);
|
||||
$this->assertEquals($releaseWithDate1['body']['key'], $movies['body']['indexes'][2]['key']);
|
||||
@@ -1476,14 +1481,15 @@ trait DatabasesBase
|
||||
'attributes' => ['actors'],
|
||||
'lengths' => [120]
|
||||
]);
|
||||
$this->assertEquals(202, $create['headers']['status-code']);
|
||||
$this->assertEquals(400, $create['headers']['status-code']);
|
||||
$this->assertEquals('Indexing an array attribute is temporarily disabled', $create['body']['message']);
|
||||
|
||||
$index = $this->client->call(Client::METHOD_GET, "/databases/{$databaseId}/collections/{$collectionId}/indexes/lengthOverrideTestIndex", [
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
]);
|
||||
$this->assertEquals([Database::ARRAY_INDEX_LENGTH], $index['body']['lengths']);
|
||||
// $index = $this->client->call(Client::METHOD_GET, "/databases/{$databaseId}/collections/{$collectionId}/indexes/lengthOverrideTestIndex", [
|
||||
// 'content-type' => 'application/json',
|
||||
// 'x-appwrite-project' => $this->getProject()['$id'],
|
||||
// 'x-appwrite-key' => $this->getProject()['apiKey']
|
||||
// ]);
|
||||
// $this->assertEquals([Database::ARRAY_INDEX_LENGTH], $index['body']['lengths']);
|
||||
|
||||
// Test case for count of lengths greater than attributes (should throw 400)
|
||||
$create = $this->client->call(Client::METHOD_POST, "/databases/{$databaseId}/collections/{$collectionId}/indexes", [
|
||||
|
||||
Reference in New Issue
Block a user