Skip to content

Commit ff3fd22

Browse files
authored
Merge pull request #520 from utopia-php/fix-filter
Add ticks on cast index
2 parents 138d1bf + 08855a5 commit ff3fd22

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed

composer.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Database/Adapter/MariaDB.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ public function createIndex(string $collection, string $id, string $type, array
772772
$attributes[$i] = "`{$attr}`{$length} {$order}";
773773

774774
if (!empty($collectionAttribute['array']) && $this->getSupportForCastIndexArray()) {
775-
$attributes[$i] = '(CAST(' . $attr . ' AS char(' . Database::ARRAY_INDEX_LENGTH . ') ARRAY))';
775+
$attributes[$i] = '(CAST(`' . $attr . '` AS char(' . Database::ARRAY_INDEX_LENGTH . ') ARRAY))';
776776
}
777777
}
778778

tests/e2e/Adapter/Base.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,13 @@ public function testCreateIndex(): void
11201120
$database = $this->getDatabase();
11211121

11221122
$database->createCollection('indexes');
1123+
1124+
/**
1125+
* Check ticks sounding cast index for reserved words
1126+
*/
1127+
$database->createAttribute('indexes', 'int', Database::VAR_INTEGER, 8, false, array:true);
1128+
$database->createIndex('indexes', 'indx8711', Database::INDEX_KEY, ['int'], [255]);
1129+
11231130
$database->createAttribute('indexes', 'name', Database::VAR_STRING, 10, false);
11241131

11251132
$database->createIndex('indexes', 'index_1', Database::INDEX_KEY, ['name']);

0 commit comments

Comments
 (0)