Skip to content

Commit 25eaa54

Browse files
authored
Fix type with space between limit and precision in SQLiteAdapter (#2329)
Signed-off-by: Matthew Peveler <[email protected]>
1 parent 74e1266 commit 25eaa54

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Phinx/Db/Adapter/SQLiteAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ public function getPhinxType(?string $sqlTypeDef): array
17941794
if ($sqlTypeDef === null) {
17951795
// in SQLite columns can legitimately have null as a type, which is distinct from the empty string
17961796
$name = null;
1797-
} elseif (!preg_match('/^([a-z]+)(_(?:integer|float|text|blob))?(?:\((\d+)(?:,(\d+))?\))?$/i', $sqlTypeDef, $match)) {
1797+
} elseif (!preg_match('/^([a-z]+)(_(?:integer|float|text|blob))?(?:\((\d+)(?:,[ ]*(\d+))?\))?$/i', $sqlTypeDef, $match)) {
17981798
// doesn't match the pattern of a type we'd know about
17991799
$name = Literal::from($sqlTypeDef);
18001800
} else {

tests/Phinx/Db/Adapter/SQLiteAdapterTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,7 +2841,9 @@ public function provideSqlTypes()
28412841
['jsonb_text', ['name' => SQLiteAdapter::PHINX_TYPE_JSONB, 'limit' => null, 'scale' => null]],
28422842
['uuid', ['name' => SQLiteAdapter::PHINX_TYPE_UUID, 'limit' => null, 'scale' => null]],
28432843
['uuid_text', ['name' => SQLiteAdapter::PHINX_TYPE_UUID, 'limit' => null, 'scale' => null]],
2844-
['decimal', ['name' => Literal::from('decimal'), 'limit' => null, 'scale' => null]],
2844+
['decimal', ['name' => SQLiteAdapter::PHINX_TYPE_DECIMAL, 'limit' => null, 'scale' => null]],
2845+
['decimal(10,5)', ['name' => SQLiteAdapter::PHINX_TYPE_DECIMAL, 'limit' => 10, 'scale' => 5]],
2846+
['decimal(10, 5)', ['name' => SQLiteAdapter::PHINX_TYPE_DECIMAL, 'limit' => 10, 'scale' => 5]],
28452847
['point', ['name' => Literal::from('point'), 'limit' => null, 'scale' => null]],
28462848
['polygon', ['name' => Literal::from('polygon'), 'limit' => null, 'scale' => null]],
28472849
['linestring', ['name' => Literal::from('linestring'), 'limit' => null, 'scale' => null]],
@@ -2917,7 +2919,7 @@ public function provideSqlTypes()
29172919
['JSONB_TEXT', ['name' => SQLiteAdapter::PHINX_TYPE_JSONB, 'limit' => null, 'scale' => null]],
29182920
['UUID', ['name' => SQLiteAdapter::PHINX_TYPE_UUID, 'limit' => null, 'scale' => null]],
29192921
['UUID_TEXT', ['name' => SQLiteAdapter::PHINX_TYPE_UUID, 'limit' => null, 'scale' => null]],
2920-
['DECIMAL', ['name' => Literal::from('decimal'), 'limit' => null, 'scale' => null]],
2922+
['DECIMAL', ['name' => SQLiteAdapter::PHINX_TYPE_DECIMAL, 'limit' => null, 'scale' => null]],
29212923
['POINT', ['name' => Literal::from('point'), 'limit' => null, 'scale' => null]],
29222924
['POLYGON', ['name' => Literal::from('polygon'), 'limit' => null, 'scale' => null]],
29232925
['LINESTRING', ['name' => Literal::from('linestring'), 'limit' => null, 'scale' => null]],

0 commit comments

Comments
 (0)