mirror of https://github.com/AMT-Cheif/drift.git
Fixes related to the new dialects feature
This commit is contained in:
parent
634b1adb72
commit
b48970d9ef
|
@ -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});
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue