diff --git a/drift/test/isolate_test.dart b/drift/test/isolate_test.dart index c27c8b2e..665d8299 100644 --- a/drift/test/isolate_test.dart +++ b/drift/test/isolate_test.dart @@ -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().having( + (e) => e.remoteCause, + 'remoteCause', + isA().having( + (e) => e.causingStatement, + 'causingStatement', + contains(r'VALUES ($1, $2)'), + ), + ), + ), + ); + }); + }); } void _runTests(FutureOr Function() spawner, bool terminateIsolate, diff --git a/drift/test/test_utils/test_utils.dart b/drift/test/test_utils/test_utils.dart index 83490aad..85afbb25 100644 --- a/drift/test/test_utils/test_utils.dart +++ b/drift/test/test_utils/test_utils.dart @@ -100,3 +100,14 @@ class CustomTable extends Table with TableInfo { return; } } + +class PretendDialectInterceptor extends QueryInterceptor { + final SqlDialect _dialect; + + PretendDialectInterceptor(this._dialect); + + @override + SqlDialect dialect(QueryExecutor executor) { + return _dialect; + } +}