mirror of https://github.com/AMT-Cheif/drift.git
Test variable bindings through isolate dialect
Regression test for #2894
This commit is contained in:
parent
364450d26a
commit
d7a26a6a9a
|
@ -240,6 +240,34 @@ void main() {
|
|||
await testWith(DatabaseConnection(NativeDatabase.memory()));
|
||||
});
|
||||
});
|
||||
|
||||
test('uses correct dialect', () async {
|
||||
// Regression test for https://github.com/simolus3/drift/issues/2894
|
||||
final isolate = await DriftIsolate.spawn(() {
|
||||
return NativeDatabase.memory()
|
||||
.interceptWith(PretendDialectInterceptor(SqlDialect.postgres));
|
||||
});
|
||||
final database = TodoDb(await isolate.connect(singleClientMode: true));
|
||||
addTearDown(database.close);
|
||||
|
||||
await database.transaction(() async {
|
||||
await expectLater(
|
||||
database.into(database.users).insertReturning(UsersCompanion.insert(
|
||||
name: 'test user', profilePicture: Uint8List(0))),
|
||||
throwsA(
|
||||
isA<DriftRemoteException>().having(
|
||||
(e) => e.remoteCause,
|
||||
'remoteCause',
|
||||
isA<SqliteException>().having(
|
||||
(e) => e.causingStatement,
|
||||
'causingStatement',
|
||||
contains(r'VALUES ($1, $2)'),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
void _runTests(FutureOr<DriftIsolate> Function() spawner, bool terminateIsolate,
|
||||
|
|
|
@ -100,3 +100,14 @@ class CustomTable extends Table with TableInfo<CustomTable, void> {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class PretendDialectInterceptor extends QueryInterceptor {
|
||||
final SqlDialect _dialect;
|
||||
|
||||
PretendDialectInterceptor(this._dialect);
|
||||
|
||||
@override
|
||||
SqlDialect dialect(QueryExecutor executor) {
|
||||
return _dialect;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue