Compare commits

...
Author SHA1 Message Date
fogelito 4d670bb47d Remove use 2025-07-20 12:06:23 +03:00
fogelito a9e53a46a6 formatting 2025-07-20 12:04:55 +03:00
fogelito e2797ab9d4 Disable index array 2025-07-20 11:57:43 +03:00
4 changed files with 43 additions and 25 deletions
+1
View File
@@ -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
View File
@@ -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
View File
@@ -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": {
+23 -15
View File
@@ -1343,8 +1343,12 @@ trait DatabasesBase
'type' => 'key',
'attributes' => ['actors'],
]);
$this->assertEquals(202, $actorsArray['headers']['status-code']);
/**
* Disabling array index due to mysql bug
* @link https://github.com/appwrite/appwrite/pull/10169
*/
$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 +1361,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 +1389,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 +1401,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 +1416,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 +1483,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", [