From bf68bb2f713f6f2882f4d1267036aba06fd679a4 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 17 Feb 2026 01:43:28 +1300 Subject: [PATCH] fix: resolve MongoDB-specific E2E test failures and $sequence type bug - Fix $sequence always cast to string (was incorrectly cast to int for numeric values) in Document.php and Row.php - Add supportForMultipleFulltextIndexes, supportForAttributeResizing, supportForSchemas console variables for MongoDB adapter - Fix testCreateIndexes to use getSupportForMultipleFulltextIndexes() instead of getSupportForRelationships() for fulltext index error branching - Fix testAttributeRowWidthLimit/testColumnRowWidthLimit to skip on databases without schema support (MongoDB) - Fix testAttributeUpdateStringResize/testColumnUpdateStringResize to skip on databases without attribute resizing support (MongoDB) Co-Authored-By: Claude Opus 4.6 --- .../Modules/Console/Http/Variables/Get.php | 3 +++ .../Response/Model/ConsoleVariables.php | 27 +++++++++++++++++++ .../Utopia/Response/Model/Document.php | 2 +- src/Appwrite/Utopia/Response/Model/Row.php | 2 +- tests/e2e/Scopes/Scope.php | 24 +++++++++++++++++ .../Databases/Legacy/DatabasesBase.php | 2 +- .../Legacy/DatabasesCustomServerTest.php | 4 +-- .../Databases/TablesDB/DatabasesBase.php | 2 +- .../TablesDB/DatabasesCustomServerTest.php | 4 +-- 9 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Console/Http/Variables/Get.php b/src/Appwrite/Platform/Modules/Console/Http/Variables/Get.php index 6d8c7d4473..d309b7c832 100644 --- a/src/Appwrite/Platform/Modules/Console/Http/Variables/Get.php +++ b/src/Appwrite/Platform/Modules/Console/Http/Variables/Get.php @@ -97,6 +97,9 @@ class Get extends Action 'supportForSpatials' => $adapter->getSupportForSpatialAttributes(), 'supportForSpatialIndexNull' => $adapter->getSupportForSpatialIndexNull(), 'supportForFulltextWildcard' => $adapter->getSupportForFulltextWildcardIndex(), + 'supportForMultipleFulltextIndexes' => $adapter->getSupportForMultipleFulltextIndexes(), + 'supportForAttributeResizing' => $adapter->getSupportForAttributeResizing(), + 'supportForSchemas' => $adapter->getSupportForSchemas(), 'maxIndexLength' => $adapter->getMaxIndexLength(), ]); diff --git a/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php b/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php index 3bbbf2cc65..721a31165f 100644 --- a/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php +++ b/src/Appwrite/Utopia/Response/Model/ConsoleVariables.php @@ -160,6 +160,33 @@ class ConsoleVariables extends Model 'example' => true, ] ) + ->addRule( + 'supportForMultipleFulltextIndexes', + [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the database adapter supports multiple fulltext indexes per collection.', + 'default' => true, + 'example' => true, + ] + ) + ->addRule( + 'supportForAttributeResizing', + [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the database adapter supports resizing attributes.', + 'default' => true, + 'example' => true, + ] + ) + ->addRule( + 'supportForSchemas', + [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether the database adapter supports fixed schemas with row width limits.', + 'default' => true, + 'example' => true, + ] + ) ->addRule( 'maxIndexLength', [ diff --git a/src/Appwrite/Utopia/Response/Model/Document.php b/src/Appwrite/Utopia/Response/Model/Document.php index a20abd7c5d..1fed9b26cf 100644 --- a/src/Appwrite/Utopia/Response/Model/Document.php +++ b/src/Appwrite/Utopia/Response/Model/Document.php @@ -85,7 +85,7 @@ class Document extends Any if (!$document->isEmpty()) { $sequence = $document->getAttribute('$sequence', ''); - $document->setAttribute('$sequence', \is_numeric($sequence) ? (int)$sequence : (string)$sequence); + $document->setAttribute('$sequence', (string)$sequence); } foreach ($document->getAttributes() as $attribute) { diff --git a/src/Appwrite/Utopia/Response/Model/Row.php b/src/Appwrite/Utopia/Response/Model/Row.php index f1726116d3..8f663f92af 100644 --- a/src/Appwrite/Utopia/Response/Model/Row.php +++ b/src/Appwrite/Utopia/Response/Model/Row.php @@ -83,7 +83,7 @@ class Row extends Any $document->removeAttribute('$collection'); $document->removeAttribute('$tenant'); $sequence = $document->getAttribute('$sequence', ''); - $document->setAttribute('$sequence', \is_numeric($sequence) ? (int)$sequence : (string)$sequence); + $document->setAttribute('$sequence', (string)$sequence); foreach ($document->getAttributes() as $column) { if (\is_array($column)) { diff --git a/tests/e2e/Scopes/Scope.php b/tests/e2e/Scopes/Scope.php index fa39554fa0..b1c652ccde 100644 --- a/tests/e2e/Scopes/Scope.php +++ b/tests/e2e/Scopes/Scope.php @@ -111,6 +111,30 @@ abstract class Scope extends TestCase return $this->getConsoleVariables()['supportForFulltextWildcard'] ?? true; } + /** + * Check if the database adapter supports multiple fulltext indexes per collection + */ + protected function getSupportForMultipleFulltextIndexes(): bool + { + return $this->getConsoleVariables()['supportForMultipleFulltextIndexes'] ?? true; + } + + /** + * Check if the database adapter supports resizing attributes + */ + protected function getSupportForAttributeResizing(): bool + { + return $this->getConsoleVariables()['supportForAttributeResizing'] ?? true; + } + + /** + * Check if the database adapter supports fixed schemas with row width limits + */ + protected function getSupportForSchemas(): bool + { + return $this->getConsoleVariables()['supportForSchemas'] ?? true; + } + /** * Get the maximum index length supported by the database adapter */ diff --git a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php index ec8a071271..65207f589d 100644 --- a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php +++ b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php @@ -1373,7 +1373,7 @@ trait DatabasesBase $this->assertEquals(400, $fulltextReleaseYear['headers']['status-code']); - if (!$this->getSupportForRelationships()) { + if (!$this->getSupportForMultipleFulltextIndexes()) { // Some databases only allow one fulltext index per collection $this->assertEquals('There is already a fulltext index in the collection', $fulltextReleaseYear['body']['message']); } else { diff --git a/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php index c1c9c1a6e7..a6a7748df9 100644 --- a/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php @@ -1375,7 +1375,7 @@ class DatabasesCustomServerTest extends Scope public function testAttributeRowWidthLimit() { - if (!$this->getSupportForRelationships()) { + if (!$this->getSupportForSchemas()) { $this->expectNotToPerformAssertions(); return; } @@ -3337,7 +3337,7 @@ class DatabasesCustomServerTest extends Scope public function testAttributeUpdateStringResize(array $data) { - if (!$this->getSupportForRelationships()) { + if (!$this->getSupportForAttributeResizing()) { $this->expectNotToPerformAssertions(); return; } diff --git a/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php b/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php index af5f403e2c..35e8829410 100644 --- a/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php +++ b/tests/e2e/Services/Databases/TablesDB/DatabasesBase.php @@ -1352,7 +1352,7 @@ trait DatabasesBase $this->assertEquals(400, $fulltextReleaseYear['headers']['status-code']); - if (!$this->getSupportForRelationships()) { + if (!$this->getSupportForMultipleFulltextIndexes()) { // Some databases only allow one fulltext index per collection $this->assertEquals('There is already a fulltext index in the collection', $fulltextReleaseYear['body']['message']); } else { diff --git a/tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php index c093693566..9f663b0bea 100644 --- a/tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php @@ -1319,7 +1319,7 @@ class DatabasesCustomServerTest extends Scope public function testColumnRowWidthLimit() { - if (!$this->getSupportForRelationships()) { + if (!$this->getSupportForSchemas()) { $this->expectNotToPerformAssertions(); return; } @@ -3266,7 +3266,7 @@ class DatabasesCustomServerTest extends Scope public function testColumnUpdateStringResize(array $data) { - if (!$this->getSupportForRelationships()) { + if (!$this->getSupportForAttributeResizing()) { $this->expectNotToPerformAssertions(); return; }