Skip to content

Commit ac336c9

Browse files
authored
Fix case sensitivity in SQLite column types (#7050)
| Q | A |------------- | ----------- | Type | bug | Fixed issues | #7049 #### Summary This change makes the regular expression case-insensitive so it matches the original casing in the definition.
1 parent cbf95bb commit ac336c9

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/Schema/SQLiteSchemaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected function _getPortableTableDefinition(array $table): string
7373
*/
7474
protected function _getPortableTableColumnDefinition(array $tableColumn): Column
7575
{
76-
$matchResult = preg_match('/^([A-Z\s]+?)(?:\s*\((\d+)(?:,\s*(\d+))?\))?$/', $tableColumn['type'], $matches);
76+
$matchResult = preg_match('/^([A-Z\s]+?)(?:\s*\((\d+)(?:,\s*(\d+))?\))?$/i', $tableColumn['type'], $matches);
7777
assert($matchResult === 1);
7878

7979
$dbType = strtolower($matches[1]);

tests/Functional/Schema/SQLiteSchemaManagerTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,28 @@ public function testListTableColumnsWithWhitespacesInTypeDeclarations(): void
191191
self::assertSame(100, $columns['bar']->getLength());
192192
}
193193

194+
public function testListTableColumnsWithMixedCaseInTypeDeclarations(): void
195+
{
196+
$sql = <<<'SQL'
197+
CREATE TABLE dbal_mixed (
198+
foo VarChar (64),
199+
bar Text (100)
200+
)
201+
SQL;
202+
203+
$this->connection->executeStatement($sql);
204+
205+
$columns = $this->schemaManager->listTableColumns('dbal_mixed');
206+
207+
self::assertCount(2, $columns);
208+
209+
self::assertArrayHasKey('foo', $columns);
210+
self::assertArrayHasKey('bar', $columns);
211+
212+
self::assertSame(Type::getType(Types::STRING), $columns['foo']->getType());
213+
self::assertSame(Type::getType(Types::TEXT), $columns['bar']->getType());
214+
}
215+
194216
public function testPrimaryKeyAutoIncrement(): void
195217
{
196218
$table = Table::editor()

0 commit comments

Comments
 (0)