mirror of https://github.com/AMT-Cheif/drift.git
Accept any type name for strict drift tables
This commit is contained in:
parent
aa38ab42f2
commit
130517473b
|
@ -135,11 +135,6 @@ class SchemaFromCreateTable {
|
||||||
return const ResolvedType(type: BasicType.blob);
|
return const ResolvedType(type: BasicType.blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _handleColumnTypeWithoutDefault(typeName) ??
|
|
||||||
const ResolvedType(type: BasicType.real);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResolvedType? _handleColumnTypeWithoutDefault(String typeName) {
|
|
||||||
final upper = typeName.toUpperCase();
|
final upper = typeName.toUpperCase();
|
||||||
if (upper.contains('INT')) {
|
if (upper.contains('INT')) {
|
||||||
return const ResolvedType(type: BasicType.int);
|
return const ResolvedType(type: BasicType.int);
|
||||||
|
@ -166,15 +161,18 @@ class SchemaFromCreateTable {
|
||||||
return const ResolvedType(type: BasicType.int);
|
return const ResolvedType(type: BasicType.int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return const ResolvedType(type: BasicType.real);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isValidTypeNameForStrictTable(String typeName) {
|
bool isValidTypeNameForStrictTable(String typeName) {
|
||||||
if (moorExtensions) {
|
if (moorExtensions) {
|
||||||
// Anything accepted by drift_dev goes, the generated table will have
|
// Drift_dev will use resolveColumnType to analyze the actual type of the
|
||||||
// a correct column type for that either way (it's transformed).
|
// column, and the generated code will always use a valid type name for
|
||||||
return _handleColumnTypeWithoutDefault(typeName) != null;
|
// that type. So, anything goes!
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// See https://www.sqlite.org/draft/stricttables.html
|
// See https://www.sqlite.org/stricttables.html
|
||||||
const allowed = {'INT', 'INTEGER', 'REAL', 'TEXT', 'BLOB', 'ANY'};
|
const allowed = {'INT', 'INTEGER', 'REAL', 'TEXT', 'BLOB', 'ANY'};
|
||||||
final upper = typeName.toUpperCase();
|
final upper = typeName.toUpperCase();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ void main() {
|
||||||
test('with a type that is only valid in drift mode', () {
|
test('with a type that is only valid in drift mode', () {
|
||||||
// https://github.com/simolus3/moor/discussions/1651
|
// https://github.com/simolus3/moor/discussions/1651
|
||||||
engineInDriftMode
|
engineInDriftMode
|
||||||
.analyze('CREATE TABLE a (c IS_DATETIME) STRICT;')
|
.analyze('CREATE TABLE a (c IS_DATETIME, b DECIMAL, c REAL) STRICT;')
|
||||||
.expectNoError();
|
.expectNoError();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue