mirror of https://github.com/AMT-Cheif/drift.git
Fox crash when serializing simple queries
This commit is contained in:
parent
b6cff50135
commit
ec2b564611
|
@ -31,9 +31,7 @@ class SchemaWriter {
|
|||
'version': _infoVersion,
|
||||
},
|
||||
'options': _serializeOptions(),
|
||||
'entities': [
|
||||
for (final entity in elements) _entityToJson(entity),
|
||||
],
|
||||
'entities': elements.map(_entityToJson).whereType<Map>().toList(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -45,9 +43,9 @@ class SchemaWriter {
|
|||
return asJson;
|
||||
}
|
||||
|
||||
Map _entityToJson(DriftElement entity) {
|
||||
String type;
|
||||
Map data;
|
||||
Map? _entityToJson(DriftElement entity) {
|
||||
String? type;
|
||||
Map? data;
|
||||
|
||||
if (entity is DriftTable) {
|
||||
type = 'table';
|
||||
|
@ -86,16 +84,20 @@ class SchemaWriter {
|
|||
'dart_info_name': entity.entityInfoName,
|
||||
'columns': [for (final column in entity.columns) _columnData(column)],
|
||||
};
|
||||
} else if (entity is DefinedSqlQuery && entity.mode == QueryMode.atCreate) {
|
||||
type = 'special-query';
|
||||
data = {
|
||||
'scenario': 'create',
|
||||
'sql': entity.sql,
|
||||
};
|
||||
} else if (entity is DefinedSqlQuery) {
|
||||
if (entity.mode == QueryMode.atCreate) {
|
||||
type = 'special-query';
|
||||
data = {
|
||||
'scenario': 'create',
|
||||
'sql': entity.sql,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
throw AssertionError('unknown entity type $entity');
|
||||
}
|
||||
|
||||
if (type == null) return null;
|
||||
|
||||
return {
|
||||
'id': _idOf(entity),
|
||||
'references': [
|
||||
|
|
|
@ -43,6 +43,8 @@ END;
|
|||
CREATE INDEX groups_name ON "groups"(name);
|
||||
|
||||
CREATE VIEW my_view AS SELECT id FROM "groups";
|
||||
|
||||
simple_query: SELECT * FROM my_view; -- not part of the schema
|
||||
''',
|
||||
'a|lib/main.dart': '''
|
||||
import 'package:drift/drift.dart';
|
||||
|
|
Loading…
Reference in New Issue