diff --git a/moor/lib/src/runtime/components/component.dart b/moor/lib/src/runtime/components/component.dart index fadf4401..e98ac535 100644 --- a/moor/lib/src/runtime/components/component.dart +++ b/moor/lib/src/runtime/components/component.dart @@ -39,7 +39,7 @@ class GenerationContext { GenerationContext.fromDb(QueryEngine database) : typeSystem = database.typeSystem, executor = database.executor, - dialect = database.executor.dialect; + dialect = database.executor?.dialect ?? SqlDialect.sqlite; GenerationContext(this.typeSystem, this.executor, {this.dialect = SqlDialect.sqlite}); diff --git a/moor/lib/src/runtime/structure/columns.dart b/moor/lib/src/runtime/structure/columns.dart index a1766a1b..f221eb80 100644 --- a/moor/lib/src/runtime/structure/columns.dart +++ b/moor/lib/src/runtime/structure/columns.dart @@ -193,17 +193,7 @@ class GeneratedIntColumn extends GeneratedColumn void writeColumnDefinition(GenerationContext into) { // todo make this work with custom constraints, default values, etc. if (hasAutoIncrement) { - String autoIncrementKeyword; - switch (into.dialect) { - case SqlDialect.sqlite: - autoIncrementKeyword = 'AUTOINCREMENT'; - break; - case SqlDialect.mysql: - autoIncrementKeyword = 'AUTO INCREMENT'; - break; - } - - into.buffer.write('${$name} $typeName PRIMARY $autoIncrementKeyword'); + into.buffer.write('${$name} $typeName PRIMARY KEY AUTOINCREMENT'); } else { super.writeColumnDefinition(into); } diff --git a/moor/test/streams_test.dart b/moor/test/streams_test.dart index d0569a5c..7a4d25e6 100644 --- a/moor/test/streams_test.dart +++ b/moor/test/streams_test.dart @@ -58,7 +58,9 @@ void main() { expect(second, emits(isEmpty)); await pumpEventQueue(times: 1); - verifyZeroInteractions(executor); + // calling executor.dialect is ok, it's needed to construct the statement + verify(executor.dialect); + verifyNoMoreInteractions(executor); }); test('every stream instance can be listened to', () async {