From 7358f545ac660909c37c8026e660ec0a815316cb Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Fri, 8 Oct 2021 22:40:58 +0200 Subject: [PATCH] Fix tests and generation in drift package --- drift/build.yaml | 21 ++++++ {moor => drift}/dart_test.yaml | 0 drift/pubspec.yaml | 2 +- drift/test/data/tables/custom_tables.g.dart | 66 ++++++++----------- drift/test/data/tables/todos.g.dart | 54 +++++---------- drift_dev/build.yaml | 6 +- drift_dev/lib/integrations/build.dart | 5 +- .../src/analyzer/dart/use_moor_parser.dart | 2 +- .../lib/src/backends/build/moor_builder.dart | 25 +++++-- drift_dev/lib/src/cli/commands/migrate.dart | 1 + .../src/writer/tables/data_class_writer.dart | 8 ++- drift_dev/lib/src/writer/utils/hash_code.dart | 31 ++++----- drift_dev/lib/src/writer/writer.dart | 5 ++ drift_dev/pubspec.yaml | 6 +- .../cyclic_moor_dart_dependency_test.dart | 4 +- .../dart/custom_row_classes_test.dart | 14 ++-- .../test/analyzer/dart/enum_columns_test.dart | 2 +- .../analyzer/dart/regression_1172_test.dart | 4 +- .../test/analyzer/dart/table_parser_test.dart | 8 +-- .../integration/dao_inheritance_test.dart | 6 +- .../integration/duplicate_tables_test.dart | 6 +- .../integration/integration_test.dart | 6 +- .../moor/create_table_reader_test.dart | 2 +- ...errors_when_importing_part_files_test.dart | 2 +- .../analyzer/moor/regression_1138_test.dart | 4 +- drift_dev/test/analyzer/repro_1280_test.dart | 6 +- drift_dev/test/analyzer/repro_967_test.dart | 6 +- drift_dev/test/analyzer/runner/task_test.dart | 4 +- .../build/generators/moor_generator_test.dart | 4 +- .../build/preprocess_builder_tests.dart | 4 +- .../find_stream_update_rules_test.dart | 8 +-- .../test/services/schema/writer_test.dart | 4 +- .../mutable_classes_integration_test.dart | 4 +- .../test/writer/utils/hash_code_test.dart | 13 +++- moor_generator/lib/integrations/build.dart | 17 ++++- 35 files changed, 200 insertions(+), 160 deletions(-) create mode 100644 drift/build.yaml rename {moor => drift}/dart_test.yaml (100%) diff --git a/drift/build.yaml b/drift/build.yaml new file mode 100644 index 00000000..3df334d4 --- /dev/null +++ b/drift/build.yaml @@ -0,0 +1,21 @@ +targets: + $default: + builders: + drift_dev: + options: + override_hash_and_equals_in_result_sets: true + use_column_name_as_json_key_when_defined_in_moor_file: true + generate_connect_constructor: true + compact_query_methods: true + write_from_json_string_constructor: true + raw_result_set_data: true + apply_converters_on_variables: true + generate_values_in_copy_with: true + named_parameters: true + new_sql_code_generation: true + scoped_dart_components: true + sqlite: + version: "3.35" + modules: + - json1 + - fts5 diff --git a/moor/dart_test.yaml b/drift/dart_test.yaml similarity index 100% rename from moor/dart_test.yaml rename to drift/dart_test.yaml diff --git a/drift/pubspec.yaml b/drift/pubspec.yaml index c90deb94..a0d6f65d 100644 --- a/drift/pubspec.yaml +++ b/drift/pubspec.yaml @@ -6,7 +6,7 @@ homepage: https://drift.simonbinder.eu/ issue_tracker: https://github.com/simolus3/moor/issues environment: - sdk: '>=2.13.0 <3.0.0' + sdk: '>=2.14.0 <3.0.0' dependencies: async: ^2.5.0 diff --git a/drift/test/data/tables/custom_tables.g.dart b/drift/test/data/tables/custom_tables.g.dart index ebc6350d..52f1ee30 100644 --- a/drift/test/data/tables/custom_tables.g.dart +++ b/drift/test/data/tables/custom_tables.g.dart @@ -68,7 +68,7 @@ class Config extends DataClass implements Insertable { factory Config.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return Config( configKey: serializer.fromJson(json['config_key']), configValue: serializer.fromJson(json['config_value']), @@ -83,7 +83,7 @@ class Config extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'config_key': serializer.toJson(configKey), 'config_value': serializer.toJson(configValue), @@ -117,10 +117,8 @@ class Config extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc( - configKey.hashCode, - $mrjc(configValue.hashCode, - $mrjc(syncState.hashCode, syncStateImplicit.hashCode)))); + int get hashCode => + Object.hash(configKey, configValue, syncState, syncStateImplicit); @override bool operator ==(Object other) => identical(this, other) || @@ -322,7 +320,7 @@ class WithDefault extends DataClass implements Insertable { factory WithDefault.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return WithDefault( a: serializer.fromJson(json['a']), b: serializer.fromJson(json['b']), @@ -335,7 +333,7 @@ class WithDefault extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'a': serializer.toJson(a), 'b': serializer.toJson(b), @@ -359,7 +357,7 @@ class WithDefault extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc(a.hashCode, b.hashCode)); + int get hashCode => Object.hash(a, b); @override bool operator ==(Object other) => identical(this, other) || @@ -601,7 +599,7 @@ class WithConstraint extends DataClass implements Insertable { factory WithConstraint.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return WithConstraint( a: serializer.fromJson(json['a']), b: serializer.fromJson(json['b']), @@ -615,7 +613,7 @@ class WithConstraint extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'a': serializer.toJson(a), 'b': serializer.toJson(b), @@ -643,7 +641,7 @@ class WithConstraint extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc(a.hashCode, $mrjc(b.hashCode, c.hashCode))); + int get hashCode => Object.hash(a, b, c); @override bool operator ==(Object other) => identical(this, other) || @@ -832,7 +830,7 @@ class MytableData extends DataClass implements Insertable { factory MytableData.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return MytableData( someid: serializer.fromJson(json['someid']), sometext: serializer.fromJson(json['sometext']), @@ -847,7 +845,7 @@ class MytableData extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'someid': serializer.toJson(someid), 'sometext': serializer.toJson(sometext), @@ -879,10 +877,7 @@ class MytableData extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc( - someid.hashCode, - $mrjc( - sometext.hashCode, $mrjc(isInserting.hashCode, somedate.hashCode)))); + int get hashCode => Object.hash(someid, sometext, isInserting, somedate); @override bool operator ==(Object other) => identical(this, other) || @@ -1079,7 +1074,7 @@ class EMail extends DataClass implements Insertable { factory EMail.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return EMail( sender: serializer.fromJson(json['sender']), title: serializer.fromJson(json['title']), @@ -1092,7 +1087,7 @@ class EMail extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'sender': serializer.toJson(sender), 'title': serializer.toJson(title), @@ -1116,8 +1111,7 @@ class EMail extends DataClass implements Insertable { } @override - int get hashCode => - $mrjf($mrjc(sender.hashCode, $mrjc(title.hashCode, body.hashCode))); + int get hashCode => Object.hash(sender, title, body); @override bool operator ==(Object other) => identical(this, other) || @@ -1289,7 +1283,7 @@ class WeirdData extends DataClass implements Insertable { factory WeirdData.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return WeirdData( sqlClass: serializer.fromJson(json['class']), textColumn: serializer.fromJson(json['text']), @@ -1302,7 +1296,7 @@ class WeirdData extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'class': serializer.toJson(sqlClass), 'text': serializer.toJson(textColumn), @@ -1323,7 +1317,7 @@ class WeirdData extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc(sqlClass.hashCode, textColumn.hashCode)); + int get hashCode => Object.hash(sqlClass, textColumn); @override bool operator ==(Object other) => identical(this, other) || @@ -1469,7 +1463,7 @@ class MyViewData extends DataClass { } factory MyViewData.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return MyViewData( configKey: serializer.fromJson(json['configKey']), configValue: serializer.fromJson(json['configValue']), @@ -1485,7 +1479,7 @@ class MyViewData extends DataClass { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'configKey': serializer.toJson(configKey), 'configValue': serializer.toJson(configValue), @@ -1519,10 +1513,8 @@ class MyViewData extends DataClass { } @override - int get hashCode => $mrjf($mrjc( - configKey.hashCode, - $mrjc(configValue.hashCode, - $mrjc(syncState.hashCode, syncStateImplicit.hashCode)))); + int get hashCode => + Object.hash(configKey, configValue, syncState, syncStateImplicit); @override bool operator ==(Object other) => identical(this, other) || @@ -1825,7 +1817,7 @@ class JsonResult extends CustomResultSet { this.value, }) : super(row); @override - int get hashCode => $mrjf($mrjc(key.hashCode, value.hashCode)); + int get hashCode => Object.hash(key, value); @override bool operator ==(Object other) => identical(this, other) || @@ -1853,7 +1845,7 @@ class MultipleResult extends CustomResultSet { this.c, }) : super(row); @override - int get hashCode => $mrjf($mrjc(a.hashCode, $mrjc(b.hashCode, c.hashCode))); + int get hashCode => Object.hash(a, b, c); @override bool operator ==(Object other) => identical(this, other) || @@ -1887,12 +1879,8 @@ class ReadRowIdResult extends CustomResultSet { this.syncStateImplicit, }) : super(row); @override - int get hashCode => $mrjf($mrjc( - rowid.hashCode, - $mrjc( - configKey.hashCode, - $mrjc(configValue.hashCode, - $mrjc(syncState.hashCode, syncStateImplicit.hashCode))))); + int get hashCode => + Object.hash(rowid, configKey, configValue, syncState, syncStateImplicit); @override bool operator ==(Object other) => identical(this, other) || diff --git a/drift/test/data/tables/todos.g.dart b/drift/test/data/tables/todos.g.dart index 6e0aff3f..c4f7bd22 100644 --- a/drift/test/data/tables/todos.g.dart +++ b/drift/test/data/tables/todos.g.dart @@ -69,7 +69,7 @@ class TodoEntry extends DataClass implements Insertable { factory TodoEntry.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return TodoEntry( id: serializer.fromJson(json['id']), title: serializer.fromJson(json['title']), @@ -85,7 +85,7 @@ class TodoEntry extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'title': serializer.toJson(title), @@ -121,12 +121,7 @@ class TodoEntry extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc( - id.hashCode, - $mrjc( - title.hashCode, - $mrjc(content.hashCode, - $mrjc(targetDate.hashCode, category.hashCode))))); + int get hashCode => Object.hash(id, title, content, targetDate, category); @override bool operator ==(Object other) => identical(this, other) || @@ -345,7 +340,7 @@ class Category extends DataClass implements Insertable { factory Category.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return Category( id: serializer.fromJson(json['id']), description: serializer.fromJson(json['description']), @@ -359,7 +354,7 @@ class Category extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'description': serializer.toJson(description), @@ -385,8 +380,7 @@ class Category extends DataClass implements Insertable { } @override - int get hashCode => - $mrjf($mrjc(id.hashCode, $mrjc(description.hashCode, priority.hashCode))); + int get hashCode => Object.hash(id, description, priority); @override bool operator ==(Object other) => identical(this, other) || @@ -577,7 +571,7 @@ class User extends DataClass implements Insertable { factory User.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return User( id: serializer.fromJson(json['id']), name: serializer.fromJson(json['name']), @@ -592,7 +586,7 @@ class User extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'id': serializer.toJson(id), 'name': serializer.toJson(name), @@ -628,12 +622,8 @@ class User extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc( - id.hashCode, - $mrjc( - name.hashCode, - $mrjc(isAwesome.hashCode, - $mrjc(profilePicture.hashCode, creationTime.hashCode))))); + int get hashCode => + Object.hash(id, name, isAwesome, profilePicture, creationTime); @override bool operator ==(Object other) => identical(this, other) || @@ -854,7 +844,7 @@ class SharedTodo extends DataClass implements Insertable { factory SharedTodo.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return SharedTodo( todo: serializer.fromJson(json['todo']), user: serializer.fromJson(json['user']), @@ -867,7 +857,7 @@ class SharedTodo extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'todo': serializer.toJson(todo), 'user': serializer.toJson(user), @@ -888,7 +878,7 @@ class SharedTodo extends DataClass implements Insertable { } @override - int get hashCode => $mrjf($mrjc(todo.hashCode, user.hashCode)); + int get hashCode => Object.hash(todo, user); @override bool operator ==(Object other) => identical(this, other) || @@ -1168,7 +1158,7 @@ class PureDefault extends DataClass implements Insertable { factory PureDefault.fromJson(Map json, {ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return PureDefault( txt: serializer.fromJson(json['txt']), ); @@ -1180,7 +1170,7 @@ class PureDefault extends DataClass implements Insertable { serializer: serializer); @override Map toJson({ValueSerializer? serializer}) { - serializer ??= moorRuntimeOptions.defaultSerializer; + serializer ??= driftRuntimeOptions.defaultSerializer; return { 'txt': serializer.toJson(txt), }; @@ -1199,7 +1189,7 @@ class PureDefault extends DataClass implements Insertable { } @override - int get hashCode => $mrjf(txt.hashCode); + int get hashCode => txt.hashCode; @override bool operator ==(Object other) => identical(this, other) || (other is PureDefault && other.txt == this.txt); @@ -1395,16 +1385,8 @@ class AllTodosWithCategoryResult extends CustomResultSet { required this.catDesc, }) : super(row); @override - int get hashCode => $mrjf($mrjc( - id.hashCode, - $mrjc( - title.hashCode, - $mrjc( - content.hashCode, - $mrjc( - targetDate.hashCode, - $mrjc(category.hashCode, - $mrjc(catId.hashCode, catDesc.hashCode))))))); + int get hashCode => + Object.hash(id, title, content, targetDate, category, catId, catDesc); @override bool operator ==(Object other) => identical(this, other) || diff --git a/drift_dev/build.yaml b/drift_dev/build.yaml index b9ff353b..557c63fd 100644 --- a/drift_dev/build.yaml +++ b/drift_dev/build.yaml @@ -17,9 +17,9 @@ builders: build_extensions: {".moor": [".temp.dart", ".dart_in_moor"]} build_to: cache auto_apply: dependents - applies_builders: ["moor_generator|moor_cleanup"] + applies_builders: ["drift_dev|cleanup"] - moor_generator: + drift_dev: import: "package:drift_dev/integrations/build.dart" builder_factories: ["moorBuilder"] build_extensions: {".dart": [".moor.g.part"]} @@ -37,6 +37,6 @@ builders: required_inputs: [".dart_in_moor"] post_process_builders: - moor_cleanup: + cleanup: import: "package:drift_dev/integrations/build.dart" builder_factory: "moorCleanup" \ No newline at end of file diff --git a/drift_dev/lib/integrations/build.dart b/drift_dev/lib/integrations/build.dart index bb2b54ad..110df91e 100644 --- a/drift_dev/lib/integrations/build.dart +++ b/drift_dev/lib/integrations/build.dart @@ -2,10 +2,11 @@ import 'package:build/build.dart'; import 'package:drift_dev/src/backends/build/moor_builder.dart'; import 'package:drift_dev/src/backends/build/preprocess_builder.dart'; -Builder moorBuilder(BuilderOptions options) => MoorSharedPartBuilder(options); +Builder moorBuilder(BuilderOptions options) => + MoorSharedPartBuilder(options, isForNewDriftPackage: true); Builder moorBuilderNotShared(BuilderOptions options) => - MoorPartBuilder(options); + MoorPartBuilder(options, isForNewDriftPackage: true); Builder preparingBuilder(BuilderOptions options) => PreprocessBuilder(); diff --git a/drift_dev/lib/src/analyzer/dart/use_moor_parser.dart b/drift_dev/lib/src/analyzer/dart/use_moor_parser.dart index 3f6dd44c..1fc3388e 100644 --- a/drift_dev/lib/src/analyzer/dart/use_moor_parser.dart +++ b/drift_dev/lib/src/analyzer/dart/use_moor_parser.dart @@ -17,7 +17,7 @@ class UseMoorParser { .whereType(); if (tablesOrNull == null) { step.reportError(ErrorInDartCode( - message: 'Could not read tables from @UseMoor annotation! \n' + message: 'Could not read tables from @DriftDatabase annotation! \n' 'Please make sure that all table classes exist.', affectedElement: element, )); diff --git a/drift_dev/lib/src/backends/build/moor_builder.dart b/drift_dev/lib/src/backends/build/moor_builder.dart index 23485d1a..3ea62e53 100644 --- a/drift_dev/lib/src/backends/build/moor_builder.dart +++ b/drift_dev/lib/src/backends/build/moor_builder.dart @@ -18,6 +18,7 @@ final _flags = Resource(() => _BuilderFlags()); mixin MoorBuilder on Builder { MoorOptions get options; + bool get isForNewDriftPackage; Writer createWriter({bool nnbd = false}) { return Writer(options, generationOptions: GenerationOptions(nnbd: nnbd)); @@ -66,12 +67,18 @@ class MoorSharedPartBuilder extends SharedPartBuilder with MoorBuilder { @override final MoorOptions options; - MoorSharedPartBuilder._(List generators, String name, this.options) + @override + final bool isForNewDriftPackage; + + MoorSharedPartBuilder._(List generators, String name, this.options, + this.isForNewDriftPackage) : super(generators, name); - factory MoorSharedPartBuilder(BuilderOptions options) { + factory MoorSharedPartBuilder(BuilderOptions options, + {bool isForNewDriftPackage = false}) { return _createBuilder(options, (generators, parsedOptions) { - return MoorSharedPartBuilder._(generators, 'moor', parsedOptions); + return MoorSharedPartBuilder._( + generators, 'moor', parsedOptions, isForNewDriftPackage); }); } @@ -94,12 +101,18 @@ class MoorPartBuilder extends PartBuilder with MoorBuilder { @override final MoorOptions options; - MoorPartBuilder._(List generators, String extension, this.options) + @override + final bool isForNewDriftPackage; + + MoorPartBuilder._(List generators, String extension, this.options, + this.isForNewDriftPackage) : super(generators, extension); - factory MoorPartBuilder(BuilderOptions options) { + factory MoorPartBuilder(BuilderOptions options, + {bool isForNewDriftPackage = false}) { return _createBuilder(options, (generators, parsedOptions) { - return MoorPartBuilder._(generators, '.moor.dart', parsedOptions); + return MoorPartBuilder._( + generators, '.moor.dart', parsedOptions, isForNewDriftPackage); }); } } diff --git a/drift_dev/lib/src/cli/commands/migrate.dart b/drift_dev/lib/src/cli/commands/migrate.dart index 8a226ce8..78e3bd5e 100644 --- a/drift_dev/lib/src/cli/commands/migrate.dart +++ b/drift_dev/lib/src/cli/commands/migrate.dart @@ -273,6 +273,7 @@ class _Moor2DriftDartRewriter extends GeneralizingAstVisitor { for (final annotation in element.metadata) { final value = annotation.computeConstantValue(); + if (value == null) return; final type = value.type; if (type is! InterfaceType) continue; diff --git a/drift_dev/lib/src/writer/tables/data_class_writer.dart b/drift_dev/lib/src/writer/tables/data_class_writer.dart index e45d3ee9..ec564092 100644 --- a/drift_dev/lib/src/writer/tables/data_class_writer.dart +++ b/drift_dev/lib/src/writer/tables/data_class_writer.dart @@ -17,6 +17,10 @@ class DataClassWriter { String get serializerType => scope.nullableType('ValueSerializer'); + String get _runtimeOptions => scope.generationOptions.writeForMoorPackage + ? 'moorRuntimeOptions' + : 'driftRuntimeOptions'; + void write() { _buffer.write('class ${table.dartTypeName} extends DataClass '); if (isInsertable) { @@ -109,7 +113,7 @@ class DataClassWriter { ..write('factory $dataClassName.fromJson(' 'Map json, {$serializerType serializer}' ') {\n') - ..write('serializer ??= moorRuntimeOptions.defaultSerializer;\n') + ..write('serializer ??= $_runtimeOptions.defaultSerializer;\n') ..write('return $dataClassName('); for (final column in table.columns) { @@ -135,7 +139,7 @@ class DataClassWriter { void _writeToJson() { _buffer.write('@override Map toJson(' '{$serializerType serializer}) {\n' - 'serializer ??= moorRuntimeOptions.defaultSerializer;\n' + 'serializer ??= $_runtimeOptions.defaultSerializer;\n' 'return {\n'); for (final column in table.columns) { diff --git a/drift_dev/lib/src/writer/utils/hash_code.dart b/drift_dev/lib/src/writer/utils/hash_code.dart index 81b2a0c0..f56efe18 100644 --- a/drift_dev/lib/src/writer/utils/hash_code.dart +++ b/drift_dev/lib/src/writer/utils/hash_code.dart @@ -1,7 +1,6 @@ -const _hashCombine = '\$mrjc'; -const _hashFinish = '\$mrjf'; - class HashCodeWriter { + static const int _maxArgsToObjectHash = 20; + const HashCodeWriter(); /// Writes an expression to calculate a hash code of an object that consists @@ -10,22 +9,20 @@ class HashCodeWriter { if (fields.isEmpty) { into.write('identityHashCode(this)'); } else if (fields.length == 1) { - into.write('$_hashFinish(${fields.last}.hashCode)'); + into.write('${fields[0]}.hashCode'); } else { - into.write('$_hashFinish('); - _writeInner(fields, into, 0); - into.write(')'); - } - } + final needsHashAll = fields.length > _maxArgsToObjectHash; - /// recursively writes a "combine(a, combine(b, c)))" expression - void _writeInner(List fields, StringBuffer into, int index) { - if (index == fields.length - 1) { - into.write('${fields.last}.hashCode'); - } else { - into.write('$_hashCombine(${fields[index]}.hashCode, '); - _writeInner(fields, into, index + 1); - into.write(')'); + into.write(needsHashAll ? 'Object.hashAll([' : 'Object.hash('); + var first = true; + for (final field in fields) { + if (!first) into.write(', '); + + into.write(field); + first = false; + } + + into.write(needsHashAll ? '])' : ')'); } } } diff --git a/drift_dev/lib/src/writer/writer.dart b/drift_dev/lib/src/writer/writer.dart index 7fb5e2db..3000c57a 100644 --- a/drift_dev/lib/src/writer/writer.dart +++ b/drift_dev/lib/src/writer/writer.dart @@ -117,11 +117,16 @@ class GenerationOptions { /// Whether companions should be generated. final bool writeCompanions; + /// Whether we're generating code for the old moor package instead of the + /// new `drift` package. + final bool writeForMoorPackage; + const GenerationOptions({ this.forSchema, this.nnbd = false, this.writeDataClasses = true, this.writeCompanions = true, + this.writeForMoorPackage = false, }); /// Whether, instead of generating the full database code, we're only diff --git a/drift_dev/pubspec.yaml b/drift_dev/pubspec.yaml index bf56936a..7d8550df 100644 --- a/drift_dev/pubspec.yaml +++ b/drift_dev/pubspec.yaml @@ -31,7 +31,7 @@ dependencies: # Dart analysis analyzer: "^2.1.0" - analyzer_plugin: ^0.7.0 + analyzer_plugin: ^0.8.0 source_span: ^1.5.5 package_config: ^2.0.0 pub_semver: ^2.0.0 @@ -50,6 +50,8 @@ dev_dependencies: build_runner: ^2.0.0 build_test: ^2.0.0 json_serializable: ^5.0.0 + # Used to test the migration from moor to drift + moor: any executables: drift_dev: @@ -57,5 +59,7 @@ executables: dependency_overrides: drift: path: ../drift + moor: + path: ../moor sqlparser: path: ../sqlparser diff --git a/drift_dev/test/analyzer/cyclic_moor_dart_dependency_test.dart b/drift_dev/test/analyzer/cyclic_moor_dart_dependency_test.dart index b8e870f5..7a3609a0 100644 --- a/drift_dev/test/analyzer/cyclic_moor_dart_dependency_test.dart +++ b/drift_dev/test/analyzer/cyclic_moor_dart_dependency_test.dart @@ -15,13 +15,13 @@ void main() { setUpAll(() { backend = TestBackend({ AssetId.parse('test_lib|lib/entry.dart'): r''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class Foos extends Table { IntColumn get id => integer().autoIncrement()(); } -@UseMoor(include: {'db.moor'}, tables: [Foos]) +@DriftDatabase(include: {'db.moor'}, tables: [Foos]) class Database {} ''', AssetId.parse('test_lib|lib/db.moor'): r''' diff --git a/drift_dev/test/analyzer/dart/custom_row_classes_test.dart b/drift_dev/test/analyzer/dart/custom_row_classes_test.dart index aa22066c..7efd7d73 100644 --- a/drift_dev/test/analyzer/dart/custom_row_classes_test.dart +++ b/drift_dev/test/analyzer/dart/custom_row_classes_test.dart @@ -13,7 +13,7 @@ void main() { setUpAll(() { state = TestState.withContent({ 'a|lib/invalid_no_unnamed_constructor.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class RowClass { RowClass.create(); @@ -22,7 +22,7 @@ class RowClass { class TableClass extends Table {} ''', 'a|lib/invalid_no_named_constructor.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class RowClass { RowClass(); @@ -32,7 +32,7 @@ class RowClass { class TableClass extends Table {} ''', 'a|lib/mismatching_type.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class RowClass { RowClass(int x); @@ -43,7 +43,7 @@ class TableClass extends Table { } ''', 'a|lib/mismatching_nullability.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class RowClass { RowClass(int x); @@ -54,7 +54,7 @@ class TableClass extends Table { } ''', 'a|lib/mismatching_type_converter.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class MyConverter extends TypeConverter { const MyConverter(); @@ -76,7 +76,7 @@ class TableClass extends Table { ''', 'a|lib/generic.dart': ''' //@dart=2.13 -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; typedef StringRow = GenericRow; typedef IntRow = GenericRow; @@ -98,7 +98,7 @@ class IntTable extends Table { ''', 'a|lib/blob.dart': ''' // @dart=2.13 -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; @UseRowClass(Cls) class Tbl extends Table { diff --git a/drift_dev/test/analyzer/dart/enum_columns_test.dart b/drift_dev/test/analyzer/dart/enum_columns_test.dart index 85227f23..cb3e1536 100644 --- a/drift_dev/test/analyzer/dart/enum_columns_test.dart +++ b/drift_dev/test/analyzer/dart/enum_columns_test.dart @@ -13,7 +13,7 @@ void main() { setUpAll(() async { state = TestState.withContent({ 'foo|lib/main.dart': ''' - import 'package:moor/moor.dart'; + import 'package:drift/drift.dart'; enum Fruits { apple, orange, banana diff --git a/drift_dev/test/analyzer/dart/regression_1172_test.dart b/drift_dev/test/analyzer/dart/regression_1172_test.dart index f517fdb2..9f282a0d 100644 --- a/drift_dev/test/analyzer/dart/regression_1172_test.dart +++ b/drift_dev/test/analyzer/dart/regression_1172_test.dart @@ -7,7 +7,7 @@ void main() { test('can define abstract tables', () async { final test = TestState.withContent({ 'a|lib/main.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; abstract class CategoriesTable extends Table { IntColumn get id => integer()(); @@ -35,7 +35,7 @@ class SocietiesCategoriesTable extends CategoriesTable { String get tableName => 'societies_categories'; } -@UseMoor(tables: [OccurrenceCategoriesTable, SocietiesCategoriesTable]) +@DriftDatabase(tables: [OccurrenceCategoriesTable, SocietiesCategoriesTable]) class Database {} ''', }); diff --git a/drift_dev/test/analyzer/dart/table_parser_test.dart b/drift_dev/test/analyzer/dart/table_parser_test.dart index 61ba3163..00381ddb 100644 --- a/drift_dev/test/analyzer/dart/table_parser_test.dart +++ b/drift_dev/test/analyzer/dart/table_parser_test.dart @@ -20,7 +20,7 @@ void main() { setUpAll(() { backend = TestBackend({ AssetId.parse('test_lib|lib/main.dart'): r''' - import 'package:moor/moor.dart'; + import 'package:drift/drift.dart'; class TableWithCustomName extends Table { @override String get tableName => 'my-fancy-table'; @@ -95,13 +95,13 @@ void main() { } ''', AssetId.parse('test_lib|lib/invalid_reference.dart'): ''' - import 'package:moor/moor.dart'; + import 'package:drift/drift.dart'; class Foo extends Table { IntColumn get id => integer().autoIncrement()(); } - @UseMoor(tables: [Foo, DoesNotExist]) + @DriftDatabase(tables: [Foo, DoesNotExist]) class Database {} ''', }); @@ -310,7 +310,7 @@ void main() { (e) => e.message, 'message', allOf( - contains('Could not read tables from @UseMoor annotation!'), + contains('Could not read tables from @DriftDatabase annotation!'), contains('Please make sure that all table classes exist.'), ), ), diff --git a/drift_dev/test/analyzer/integration/dao_inheritance_test.dart b/drift_dev/test/analyzer/integration/dao_inheritance_test.dart index 4d6140f5..8e275750 100644 --- a/drift_dev/test/analyzer/integration/dao_inheritance_test.dart +++ b/drift_dev/test/analyzer/integration/dao_inheritance_test.dart @@ -9,14 +9,14 @@ void main() { test('supports inheritance for daos', () async { final state = TestState.withContent({ 'a|lib/database.dart': r''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class Products extends Table { IntColumn get id => integer().autoIncrement()(); TextColumn get name => text()(); } -@UseMoor(tables: [Products], daos: [ProductsDao]) +@DriftDatabase(tables: [Products], daos: [ProductsDao]) class MyDatabase {} abstract class BaseDao @@ -35,7 +35,7 @@ abstract class BaseProductsDao extends BaseDao { BaseProductsDao(MyDatabase db): super(db, db.products); } -@UseDao(tables: [ProductTable]) +@DriftAccessor(tables: [ProductTable]) class ProductsDao extends BaseProductsDao with _$ProductDaoMixin { ProductsDao(MyDatabase db): super(db); } diff --git a/drift_dev/test/analyzer/integration/duplicate_tables_test.dart b/drift_dev/test/analyzer/integration/duplicate_tables_test.dart index 5d1aac9f..bf87bcbd 100644 --- a/drift_dev/test/analyzer/integration/duplicate_tables_test.dart +++ b/drift_dev/test/analyzer/integration/duplicate_tables_test.dart @@ -8,18 +8,18 @@ void main() { test("tables imported in two ways aren't duplicated", () async { final state = TestState.withContent({ 'foo|lib/main.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; import 'table.dart'; -@UseMoor(tables: [Users], include: {'file.moor'}) +@DriftDatabase(tables: [Users], include: {'file.moor'}) class MyDatabase {} ''', 'foo|lib/file.moor': ''' import 'table.dart'; ''', 'foo|lib/table.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class Users extends Table { IntColumn get id => integer().autoIncrement()(); diff --git a/drift_dev/test/analyzer/integration/integration_test.dart b/drift_dev/test/analyzer/integration/integration_test.dart index a7072c0f..fe75d220 100644 --- a/drift_dev/test/analyzer/integration/integration_test.dart +++ b/drift_dev/test/analyzer/integration/integration_test.dart @@ -14,7 +14,7 @@ void main() { setUpAll(() { state = TestState.withContent({ 'test_lib|lib/database.dart': r''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; import 'another.dart'; // so that the resolver picks it up @@ -27,7 +27,7 @@ class UsedLanguages extends Table { Set get primaryKey => {language, library}; } -@UseMoor( +@DriftDatabase( tables: [UsedLanguages], include: {'package:test_lib/tables.moor'}, queries: { @@ -54,7 +54,7 @@ joinTest: SELECT * FROM reference_test r INNER JOIN libraries l ON l.id = r.library; ''', 'test_lib|lib/another.dart': r''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class ProgrammingLanguages extends Table { IntColumn get id => integer().autoIncrement()(); diff --git a/drift_dev/test/analyzer/moor/create_table_reader_test.dart b/drift_dev/test/analyzer/moor/create_table_reader_test.dart index 7ebb2f31..cd6d30c5 100644 --- a/drift_dev/test/analyzer/moor/create_table_reader_test.dart +++ b/drift_dev/test/analyzer/moor/create_table_reader_test.dart @@ -68,7 +68,7 @@ void main() { ); ''', 'foo|lib/enum.dart': ''' - import 'package:moor/moor.dart'; + import 'package:drift/drift.dart'; enum Fruits { apple, orange, banane diff --git a/drift_dev/test/analyzer/moor/errors_when_importing_part_files_test.dart b/drift_dev/test/analyzer/moor/errors_when_importing_part_files_test.dart index 272ebe84..0b00d155 100644 --- a/drift_dev/test/analyzer/moor/errors_when_importing_part_files_test.dart +++ b/drift_dev/test/analyzer/moor/errors_when_importing_part_files_test.dart @@ -9,7 +9,7 @@ void main() { test('reports an error when importing a part file into .moor', () async { final state = TestState.withContent({ 'a|lib/base.dart': ''' - import 'package:moor/moor.dart'; + import 'package:drift/drift.dart'; part 'tables.dart'; ''', diff --git a/drift_dev/test/analyzer/moor/regression_1138_test.dart b/drift_dev/test/analyzer/moor/regression_1138_test.dart index e9f3cba2..fe79b575 100644 --- a/drift_dev/test/analyzer/moor/regression_1138_test.dart +++ b/drift_dev/test/analyzer/moor/regression_1138_test.dart @@ -8,7 +8,7 @@ void main() { test('moor files can import original dart source', () async { final state = TestState.withContent({ 'a|lib/base.dart': r''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; part 'base.g.dart'; @@ -30,7 +30,7 @@ class Units extends Table { IntColumn get id => integer().autoIncrement()(); } -@UseMoor(include: {'customizedSQL.moor'}) +@DriftDatabase(include: {'customizedSQL.moor'}) class AppDatabase extends _$AppDatabase { AppDatabase() : super(FlutterQueryExecutor.inDatabaseFolder( diff --git a/drift_dev/test/analyzer/repro_1280_test.dart b/drift_dev/test/analyzer/repro_1280_test.dart index 3291e2b0..9fe710a3 100644 --- a/drift_dev/test/analyzer/repro_1280_test.dart +++ b/drift_dev/test/analyzer/repro_1280_test.dart @@ -8,12 +8,12 @@ void main() { test('analyzes views referencing Dart tables', () async { final state = TestState.withContent({ 'a|lib/db.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; import 'dart:io'; import 'entities/person.dart'; -@UseMoor(tables: [Persons], include: {'query.moor'}) +@DriftDatabase(tables: [Persons], include: {'query.moor'}) class MyDatabase { MyDatabase() : super(_openConnection()); @override @@ -33,7 +33,7 @@ SELECT id, name, last_name, '...' AS full_name FROM persons; ''', 'a|lib/entities/person.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class Persons extends Table { IntColumn get id => integer().autoIncrement()(); diff --git a/drift_dev/test/analyzer/repro_967_test.dart b/drift_dev/test/analyzer/repro_967_test.dart index 6cca674b..fb18459a 100644 --- a/drift_dev/test/analyzer/repro_967_test.dart +++ b/drift_dev/test/analyzer/repro_967_test.dart @@ -8,15 +8,15 @@ void main() { test('gracefully handles daos with invalid types', () async { final state = TestState.withContent({ 'foo|lib/bar.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class Foos extends Table { IntColumn get id => integer().autoIncrement()(); } -@UseMoor() class Db {} +@DriftDatabase() class Db {} -@UseDao(tables: [Foos, Db]) +@DriftAccessor(tables: [Foos, Db]) class Dao extends DatabaseAccessor {} ''', }); diff --git a/drift_dev/test/analyzer/runner/task_test.dart b/drift_dev/test/analyzer/runner/task_test.dart index 35dcb7a2..d102f234 100644 --- a/drift_dev/test/analyzer/runner/task_test.dart +++ b/drift_dev/test/analyzer/runner/task_test.dart @@ -29,9 +29,9 @@ import 'b.moor'; test('in a dart file', () async { final state = TestState.withContent({ 'foo|lib/a.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; -@UseMoor(include: {'b.moor'}) +@DriftDatabase(include: {'b.moor'}) class Database { } diff --git a/drift_dev/test/backends/build/generators/moor_generator_test.dart b/drift_dev/test/backends/build/generators/moor_generator_test.dart index 485a98d2..66e6c1f7 100644 --- a/drift_dev/test/backends/build/generators/moor_generator_test.dart +++ b/drift_dev/test/backends/build/generators/moor_generator_test.dart @@ -27,9 +27,9 @@ void main() { 'foo|lib/a.dart': ''' // @dart = 2.1 -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; -@UseMoor(tables: []) +@DriftDatabase(tables: []) class Database {} ''', }, diff --git a/drift_dev/test/backends/build/preprocess_builder_tests.dart b/drift_dev/test/backends/build/preprocess_builder_tests.dart index 08ab9fcc..d4583beb 100644 --- a/drift_dev/test/backends/build/preprocess_builder_tests.dart +++ b/drift_dev/test/backends/build/preprocess_builder_tests.dart @@ -24,7 +24,7 @@ CREATE TABLE foo ( ); ''', 'foo|converter.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class MyConverter extends TypeConverter { const MyConverter(); @@ -72,7 +72,7 @@ CREATE TABLE foo ( import 'converter.dart'; ''', 'foo|converter.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class MyConverter extends TypeConverter { const MyConverter(); diff --git a/drift_dev/test/services/find_stream_update_rules_test.dart b/drift_dev/test/services/find_stream_update_rules_test.dart index 1c9bbaf8..43a13190 100644 --- a/drift_dev/test/services/find_stream_update_rules_test.dart +++ b/drift_dev/test/services/find_stream_update_rules_test.dart @@ -24,9 +24,9 @@ BEGIN END; ''', 'foo|lib/main.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; -@UseMoor(include: {'a.moor'}) +@DriftDatabase(include: {'a.moor'}) class MyDatabase {} ''' }); @@ -80,9 +80,9 @@ CREATE TABLE unaffected_on_update ( ); ''', 'foo|lib/main.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; -@UseMoor(include: {'a.moor'}) +@DriftDatabase(include: {'a.moor'}) class MyDatabase {} ''' }); diff --git a/drift_dev/test/services/schema/writer_test.dart b/drift_dev/test/services/schema/writer_test.dart index 9f774ac1..1699a0b5 100644 --- a/drift_dev/test/services/schema/writer_test.dart +++ b/drift_dev/test/services/schema/writer_test.dart @@ -43,7 +43,7 @@ END; CREATE INDEX groups_name ON "groups"(name); ''', 'foo|lib/main.dart': ''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; class Users extends Table { IntColumn get id => integer().autoIncrement()(); @@ -60,7 +60,7 @@ class SettingsConverter extends TypeConverter { Settings mapToDart(String db) => Settings(); } -@UseMoor(include: {'a.moor'}, tables: [Users]) +@DriftDatabase(include: {'a.moor'}, tables: [Users]) class Database {} ''', }, options: const MoorOptions.defaults(modules: [SqlModule.fts5])); diff --git a/drift_dev/test/writer/mutable_classes_integration_test.dart b/drift_dev/test/writer/mutable_classes_integration_test.dart index 12ff6255..db0e80c2 100644 --- a/drift_dev/test/writer/mutable_classes_integration_test.dart +++ b/drift_dev/test/writer/mutable_classes_integration_test.dart @@ -10,7 +10,7 @@ import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; const _testInput = r''' -import 'package:moor/moor.dart'; +import 'package:drift/drift.dart'; part 'main.moor.dart'; @@ -19,7 +19,7 @@ class Users extends Table { TextColumn get name => text()(); } -@UseMoor( +@DriftDatabase( tables: [Users], queries: { 'someQuery': 'SELECT 1 AS foo, 2 AS bar;', diff --git a/drift_dev/test/writer/utils/hash_code_test.dart b/drift_dev/test/writer/utils/hash_code_test.dart index 5ec503f9..0f762ff4 100644 --- a/drift_dev/test/writer/utils/hash_code_test.dart +++ b/drift_dev/test/writer/utils/hash_code_test.dart @@ -1,4 +1,6 @@ //@dart=2.9 + +import 'package:charcode/ascii.dart'; import 'package:drift_dev/src/writer/utils/hash_code.dart'; import 'package:test/test.dart'; @@ -12,13 +14,20 @@ void main() { test('hash code for a single field', () { final buffer = StringBuffer(); const HashCodeWriter().writeHashCode(['a'], buffer); - expect(buffer.toString(), r'$mrjf(a.hashCode)'); + expect(buffer.toString(), r'a.hashCode'); }); test('hash code for multiple fields', () { final buffer = StringBuffer(); const HashCodeWriter().writeHashCode(['a', 'b', 'c'], buffer); + expect(buffer.toString(), r'Object.hash(a, b, c)'); + }); + + test('hash code for lots of fields', () { + final buffer = StringBuffer(); + const HashCodeWriter().writeHashCode( + List.generate(26, (index) => String.fromCharCode($a + index)), buffer); expect(buffer.toString(), - r'$mrjf($mrjc(a.hashCode, $mrjc(b.hashCode, c.hashCode)))'); + r'Object.hashAll([a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z])'); }); } diff --git a/moor_generator/lib/integrations/build.dart b/moor_generator/lib/integrations/build.dart index 863f53e4..6027a1fd 100644 --- a/moor_generator/lib/integrations/build.dart +++ b/moor_generator/lib/integrations/build.dart @@ -1 +1,16 @@ -export 'package:drift_dev/integrations/build.dart'; +// ignore_for_file: implementation_imports +import 'package:build/build.dart'; +import 'package:drift_dev/src/backends/build/moor_builder.dart'; +import 'package:drift_dev/src/backends/build/preprocess_builder.dart'; + +Builder moorBuilder(BuilderOptions options) => + MoorSharedPartBuilder(options, isForNewDriftPackage: false); + +Builder moorBuilderNotShared(BuilderOptions options) => + MoorPartBuilder(options, isForNewDriftPackage: false); + +Builder preparingBuilder(BuilderOptions options) => PreprocessBuilder(); + +PostProcessBuilder moorCleanup(BuilderOptions options) { + return const FileDeletingBuilder(['.temp.dart']); +}