diff --git a/sqlparser/lib/src/analysis/schema/from_create_table.dart b/sqlparser/lib/src/analysis/schema/from_create_table.dart index 76e7d435..f3380de3 100644 --- a/sqlparser/lib/src/analysis/schema/from_create_table.dart +++ b/sqlparser/lib/src/analysis/schema/from_create_table.dart @@ -135,11 +135,6 @@ class SchemaFromCreateTable { return const ResolvedType(type: BasicType.blob); } - return _handleColumnTypeWithoutDefault(typeName) ?? - const ResolvedType(type: BasicType.real); - } - - ResolvedType? _handleColumnTypeWithoutDefault(String typeName) { final upper = typeName.toUpperCase(); if (upper.contains('INT')) { return const ResolvedType(type: BasicType.int); @@ -166,15 +161,18 @@ class SchemaFromCreateTable { return const ResolvedType(type: BasicType.int); } } + + return const ResolvedType(type: BasicType.real); } bool isValidTypeNameForStrictTable(String typeName) { if (moorExtensions) { - // Anything accepted by drift_dev goes, the generated table will have - // a correct column type for that either way (it's transformed). - return _handleColumnTypeWithoutDefault(typeName) != null; + // Drift_dev will use resolveColumnType to analyze the actual type of the + // column, and the generated code will always use a valid type name for + // that type. So, anything goes! + return true; } else { - // See https://www.sqlite.org/draft/stricttables.html + // See https://www.sqlite.org/stricttables.html const allowed = {'INT', 'INTEGER', 'REAL', 'TEXT', 'BLOB', 'ANY'}; final upper = typeName.toUpperCase(); diff --git a/sqlparser/test/analysis/errors/create_table_errors_test.dart b/sqlparser/test/analysis/errors/create_table_errors_test.dart index 1185a1e6..99c0bc86 100644 --- a/sqlparser/test/analysis/errors/create_table_errors_test.dart +++ b/sqlparser/test/analysis/errors/create_table_errors_test.dart @@ -40,7 +40,7 @@ void main() { test('with a type that is only valid in drift mode', () { // https://github.com/simolus3/moor/discussions/1651 engineInDriftMode - .analyze('CREATE TABLE a (c IS_DATETIME) STRICT;') + .analyze('CREATE TABLE a (c IS_DATETIME, b DECIMAL, c REAL) STRICT;') .expectNoError(); }); });