diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 4a5426dc95..636f8f5d79 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -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)) { diff --git a/composer.json b/composer.json index 5e90143b13..5d82a196ec 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/composer.lock b/composer.lock index ea3b3459a6..e4e5614b4c 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": "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": { diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 0b19a8966f..da8f12170f 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -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", [