mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
436ced3f1f
commit
bf68bb2f71
9 files changed
+62
-8
No files matched your search
@@ -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(),
|
||||
]);
|
||||
|
||||
|
||||
@@ -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',
|
||||
[
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user