11import 'dart:async' ;
22import 'dart:math' ;
33
4+ import 'package:glob/glob.dart' ;
5+ import 'package:glob/list_local_fs.dart' ;
46import 'package:sqlite_async/sqlite_async.dart' ;
57import 'package:sqlite_async/src/database_utils.dart' ;
68import 'package:test/test.dart' ;
@@ -19,6 +21,7 @@ void main() {
1921 'CREATE TABLE customers(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)' );
2022 await tx.execute (
2123 'CREATE TABLE other_customers(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)' );
24+ await tx.execute ('CREATE VIEW assets_alias AS SELECT * FROM assets' );
2225 });
2326 }
2427
@@ -30,22 +33,36 @@ void main() {
3033 await cleanDb (path: path);
3134 });
3235
33- // TODO: Test on different SQLite versions
34- test ('getSourceTables' , () async {
35- final db = await setupDatabase (path: path);
36- await createTables (db);
36+ for (var sqlite in findSqliteLibraries ()) {
37+ test ('getSourceTables - $sqlite ' , () async {
38+ final db = SqliteDatabase .withFactory (
39+ openFactory: TestSqliteOpenFactory (path: path, sqlitePath: sqlite));
40+ await db.initialize ();
41+ await createTables (db);
3742
38- final tables = await getSourceTables (db,
39- 'SELECT * FROM assets INNER JOIN customers ON assets.customer_id = customers.id' );
40- expect (tables, equals ({'assets' , 'customers' }));
43+ var versionRow = await db.get ('SELECT sqlite_version() as version' );
44+ print ('Testing SQLite ${versionRow ['version' ]} - $sqlite ' );
4145
42- final tables2 = await getSourceTables (db,
43- 'SELECT count() FROM assets INNER JOIN "other_customers" AS oc ON assets.customer_id = oc .id AND assets.make = oc.name ' );
44- expect (tables2 , equals ({'assets' , 'other_customers ' }));
46+ final tables = await getSourceTables (db,
47+ 'SELECT * FROM assets INNER JOIN customers ON assets.customer_id = customers .id' );
48+ expect (tables , equals ({'assets' , 'customers ' }));
4549
46- final tables3 = await getSourceTables (db, 'SELECT count() FROM assets' );
47- expect (tables3, equals ({'assets' }));
48- });
50+ final tables2 = await getSourceTables (db,
51+ 'SELECT count() FROM assets INNER JOIN "other_customers" AS oc ON assets.customer_id = oc.id AND assets.make = oc.name' );
52+ expect (tables2, equals ({'assets' , 'other_customers' }));
53+
54+ final tables3 = await getSourceTables (db, 'SELECT count() FROM assets' );
55+ expect (tables3, equals ({'assets' }));
56+
57+ final tables4 =
58+ await getSourceTables (db, 'SELECT count() FROM assets_alias' );
59+ expect (tables4, equals ({'assets' }));
60+
61+ final tables5 =
62+ await getSourceTables (db, 'SELECT sqlite_version() as version' );
63+ expect (tables5, equals (< String > {}));
64+ });
65+ }
4966
5067 test ('watch' , () async {
5168 final db = await setupDatabase (path: path);
0 commit comments