Fixes related to the new dialects feature

This commit is contained in:
Simon Binder 2019-07-29 15:46:00 +02:00
parent 634b1adb72
commit b48970d9ef
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
3 changed files with 5 additions and 13 deletions

View File

@ -39,7 +39,7 @@ class GenerationContext {
GenerationContext.fromDb(QueryEngine database) GenerationContext.fromDb(QueryEngine database)
: typeSystem = database.typeSystem, : typeSystem = database.typeSystem,
executor = database.executor, executor = database.executor,
dialect = database.executor.dialect; dialect = database.executor?.dialect ?? SqlDialect.sqlite;
GenerationContext(this.typeSystem, this.executor, GenerationContext(this.typeSystem, this.executor,
{this.dialect = SqlDialect.sqlite}); {this.dialect = SqlDialect.sqlite});

View File

@ -193,17 +193,7 @@ class GeneratedIntColumn extends GeneratedColumn<int, IntType>
void writeColumnDefinition(GenerationContext into) { void writeColumnDefinition(GenerationContext into) {
// todo make this work with custom constraints, default values, etc. // todo make this work with custom constraints, default values, etc.
if (hasAutoIncrement) { if (hasAutoIncrement) {
String autoIncrementKeyword; into.buffer.write('${$name} $typeName PRIMARY KEY AUTOINCREMENT');
switch (into.dialect) {
case SqlDialect.sqlite:
autoIncrementKeyword = 'AUTOINCREMENT';
break;
case SqlDialect.mysql:
autoIncrementKeyword = 'AUTO INCREMENT';
break;
}
into.buffer.write('${$name} $typeName PRIMARY $autoIncrementKeyword');
} else { } else {
super.writeColumnDefinition(into); super.writeColumnDefinition(into);
} }

View File

@ -58,7 +58,9 @@ void main() {
expect(second, emits(isEmpty)); expect(second, emits(isEmpty));
await pumpEventQueue(times: 1); 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 { test('every stream instance can be listened to', () async {