Skip to content

Commit 71fe6dc

Browse files
authored
Merge pull request #6944 from morozov/sqlite-column-type-parsing-cleanup
Clean up SQLite column definition parsing
2 parents 6510689 + 7aa2fa5 commit 71fe6dc

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/Schema/SQLiteSchemaManager.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
use function str_replace;
3333
use function strcasecmp;
3434
use function strtolower;
35-
use function trim;
3635

3736
use const CASE_LOWER;
3837

@@ -74,21 +73,21 @@ protected function _getPortableTableDefinition(array $table): string
7473
*/
7574
protected function _getPortableTableColumnDefinition(array $tableColumn): Column
7675
{
77-
$matchResult = preg_match('/^([^()]*)\\s*(\\(((\\d+)(,\\s*(\\d+))?)\\))?/', $tableColumn['type'], $matches);
76+
$matchResult = preg_match('/^([A-Z\s]+?)(?:\s*\((\d+)(?:,\s*(\d+))?\))?$/', $tableColumn['type'], $matches);
7877
assert($matchResult === 1);
7978

80-
$dbType = trim(strtolower($matches[1]));
79+
$dbType = strtolower($matches[1]);
8180

8281
$length = $precision = null;
8382
$fixed = $unsigned = false;
8483
$scale = 0;
8584

86-
if (isset($matches[4])) {
87-
if (isset($matches[6])) {
88-
$precision = (int) $matches[4];
89-
$scale = (int) $matches[6];
85+
if (isset($matches[2])) {
86+
if (isset($matches[3])) {
87+
$precision = (int) $matches[2];
88+
$scale = (int) $matches[3];
9089
} else {
91-
$length = (int) $matches[4];
90+
$length = (int) $matches[2];
9291
}
9392
}
9493

0 commit comments

Comments
 (0)