From 464b97d1508824e47bfdbc187db6e87ba7f64e1c Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 28 May 2026 09:59:36 +0300 Subject: [PATCH] disable array index create --- .../Databases/Http/Databases/Collections/Create.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php index 3a53a49579..4bacbb8f77 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Create.php @@ -172,7 +172,7 @@ class Create extends Action $indexDocuments = []; try { foreach ($indexes as $indexDef) { - $idxDoc = $this->buildIndexDocument($database, $collection, $indexDef, $collectionAttributes); + $idxDoc = $this->buildIndexDocument($database, $collection, $indexDef, $collectionAttributes, $dbForDatabases); $collectionIndexes[] = $idxDoc['collection']; $indexDocuments[] = $idxDoc['document']; } @@ -346,7 +346,7 @@ class Create extends Action * * @return array{collection: Document, document: Document} */ - protected function buildIndexDocument(Document $database, Document $collection, array $indexDef, array $attributeDocuments): array + protected function buildIndexDocument(Document $database, Document $collection, array $indexDef, array $attributeDocuments, Database $dbForDatabases): array { $key = $indexDef['key']; $type = $indexDef['type']; @@ -370,6 +370,11 @@ class Create extends Action if ($attrArray === true) { $lengths[$i] = Database::MAX_ARRAY_INDEX_LENGTH; $orders[$i] = null; + + if($dbForDatabases->getAdapter()->getSupportForAttributes()){ + // Because of a bug in MySQL, we cannot create indexes on array attributes for now, otherwise queries break. + throw new Exception(Exception::INDEX_INVALID, 'Creating indexes on array attributes is not currently supported.'); + } } } else { if (empty($lengths[$i])) {