Skip to content

Commit 1116795

Browse files
update from master
2 parents decb557 + 34e3161 commit 1116795

File tree

8 files changed

+24
-61
lines changed

8 files changed

+24
-61
lines changed

.github/workflows/test.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ jobs:
3030
strategy:
3131
matrix:
3232
include:
33-
- sqlite_version: '3440200'
34-
sqlite_url: 'https://www.sqlite.org/2023/sqlite-autoconf-3440200.tar.gz'
33+
- sqlite_version: "3440200"
34+
sqlite_url: "https://www.sqlite.org/2023/sqlite-autoconf-3440200.tar.gz"
3535
dart_sdk: 3.3.3
36-
- sqlite_version: '3430200'
37-
sqlite_url: 'https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz'
36+
- sqlite_version: "3430200"
37+
sqlite_url: "https://www.sqlite.org/2023/sqlite-autoconf-3430200.tar.gz"
3838
dart_sdk: 3.3.3
39-
- sqlite_version: '3420000'
40-
sqlite_url: 'https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz'
39+
- sqlite_version: "3420000"
40+
sqlite_url: "https://www.sqlite.org/2023/sqlite-autoconf-3420000.tar.gz"
4141
dart_sdk: 3.3.3
42-
- sqlite_version: '3410100'
43-
sqlite_url: 'https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz'
42+
- sqlite_version: "3410100"
43+
sqlite_url: "https://www.sqlite.org/2023/sqlite-autoconf-3410100.tar.gz"
4444
dart_sdk: 3.3.3
45-
- sqlite_version: '3380000'
46-
sqlite_url: 'https://www.sqlite.org/2022/sqlite-autoconf-3380000.tar.gz'
45+
- sqlite_version: "3380000"
46+
sqlite_url: "https://www.sqlite.org/2022/sqlite-autoconf-3380000.tar.gz"
4747
dart_sdk: 3.3.3
4848
steps:
4949
- uses: actions/checkout@v3

lib/sqlite3_common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// Exports common Sqlite3 exports which are available on web and ffi environments
1+
// Exports common Sqlite3 exports which are available in different environments.
22
export 'package:sqlite3/common.dart';
File renamed without changes.

test/native/basic_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,11 @@ void main() {
305305
// 4. Now second connection is ready. Second query has two connections to choose from.
306306
// 5. However, first connection is closed, so it's removed from the pool.
307307
// 6. Triggers `Concurrent modification during iteration: Instance(length:1) of '_GrowableList'`
308-
final db = await testUtils.setupDatabase(path: path, initStatements: [
308+
final db = SqliteDatabase.withFactory(
309+
await testUtils.testFactory(path: path, initStatements: [
309310
// Second connection to sleep more than first connection
310311
'SELECT test_sleep(test_connection_number() * 10)'
311-
]);
312+
]));
312313
await db.initialize();
313314

314315
final future1 = db.get('SELECT test_sleep(10) as sleep');

test/native/watch_test.dart

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,14 @@ import 'dart:math';
55

66
import 'package:sqlite3/common.dart';
77
import 'package:sqlite_async/sqlite_async.dart';
8-
import 'package:sqlite_async/src/utils/database_utils.dart';
98
import 'package:test/test.dart';
109

1110
import '../utils/test_utils_impl.dart';
11+
import '../watch_test.dart';
1212

1313
final testUtils = TestUtils();
1414

1515
void main() {
16-
createTables(SqliteDatabase db) async {
17-
await db.writeTransaction((tx) async {
18-
await tx.execute(
19-
'CREATE TABLE assets(id INTEGER PRIMARY KEY AUTOINCREMENT, make TEXT, customer_id INTEGER)');
20-
await tx.execute('CREATE INDEX assets_customer ON assets(customer_id)');
21-
await tx.execute(
22-
'CREATE TABLE customers(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)');
23-
await tx.execute(
24-
'CREATE TABLE other_customers(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT)');
25-
await tx.execute('CREATE VIEW assets_alias AS SELECT * FROM assets');
26-
});
27-
}
28-
2916
group('Query Watch Tests', () {
3017
late String path;
3118

@@ -34,37 +21,6 @@ void main() {
3421
await testUtils.cleanDb(path: path);
3522
});
3623

37-
for (var sqlite in testUtils.findSqliteLibraries()) {
38-
test('getSourceTables - $sqlite', () async {
39-
final db = SqliteDatabase.withFactory(
40-
await testUtils.testFactory(path: path, sqlitePath: sqlite));
41-
await db.initialize();
42-
await createTables(db);
43-
44-
var versionRow = await db.get('SELECT sqlite_version() as version');
45-
print('Testing SQLite ${versionRow['version']} - $sqlite');
46-
47-
final tables = await getSourceTables(db,
48-
'SELECT * FROM assets INNER JOIN customers ON assets.customer_id = customers.id');
49-
expect(tables, equals({'assets', 'customers'}));
50-
51-
final tables2 = await getSourceTables(db,
52-
'SELECT count() FROM assets INNER JOIN "other_customers" AS oc ON assets.customer_id = oc.id AND assets.make = oc.name');
53-
expect(tables2, equals({'assets', 'other_customers'}));
54-
55-
final tables3 = await getSourceTables(db, 'SELECT count() FROM assets');
56-
expect(tables3, equals({'assets'}));
57-
58-
final tables4 =
59-
await getSourceTables(db, 'SELECT count() FROM assets_alias');
60-
expect(tables4, equals({'assets'}));
61-
62-
final tables5 =
63-
await getSourceTables(db, 'SELECT sqlite_version() as version');
64-
expect(tables5, equals(<String>{}));
65-
});
66-
}
67-
6824
test('watch in isolate', () async {
6925
final db = await testUtils.setupDatabase(path: path);
7026
await createTables(db);

test/utils/abstract_test_utils.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ abstract class AbstractTestUtils {
2222
Future<TestDefaultSqliteOpenFactory> testFactory(
2323
{String? path,
2424
String sqlitePath = '',
25+
List<String> initStatements = const [],
2526
SqliteOptions options = const SqliteOptions.defaults()}) async {
2627
return TestDefaultSqliteOpenFactory(
27-
path: path ?? dbPath(), sqliteOptions: options);
28+
path: path ?? dbPath(),
29+
sqliteOptions: options,
30+
);
2831
}
2932

3033
/// Creates a SqliteDatabaseConnection

test/utils/web_test_utils.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ class TestUtils extends AbstractTestUtils {
4040
Future<TestDefaultSqliteOpenFactory> testFactory(
4141
{String? path,
4242
String? sqlitePath,
43+
List<String> initStatements = const [],
4344
SqliteOptions options = const SqliteOptions.defaults()}) async {
4445
await _isInitialized;
45-
return super.testFactory(path: path, options: webOptions);
46+
return super.testFactory(
47+
path: path, options: webOptions, initStatements: initStatements);
4648
}
4749

4850
@override
@@ -56,6 +58,7 @@ class TestUtils extends AbstractTestUtils {
5658

5759
@override
5860
List<String> findSqliteLibraries() {
59-
return [];
61+
// Maintains consistency with native tests
62+
return ['sqlite3.wasm'];
6063
}
6164
}
File renamed without changes.

0 commit comments

Comments
 (0)