Skip to content

Commit 10f430b

Browse files
update from main
2 parents daf9331 + 26315e1 commit 10f430b

8 files changed

+27
-26
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.7.0
2+
3+
- BREAKING CHANGE: Update all Database types to use a `CommonDatabase` interface.
4+
- Update `openDB` and `open` methods to be synchronous.
5+
- Fix `ArgumentError (Invalid argument(s): argument value for 'return_value' is null)` in sqlite3 when closing the database connection by upgrading to version 2.4.4.
6+
17
## 0.7.0-alpha.5
28

39
- The dependency for the `Drift` package is now removed in favour of using the new `sqlite3_web` package.

example/custom_functions_example.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:async';
21
import 'dart:io';
32
import 'dart:isolate';
43

@@ -11,8 +10,8 @@ class TestOpenFactory extends DefaultSqliteOpenFactory {
1110
TestOpenFactory({required super.path, super.sqliteOptions});
1211

1312
@override
14-
FutureOr<CommonDatabase> open(SqliteOpenOptions options) async {
15-
final db = await super.open(options);
13+
CommonDatabase open(SqliteOpenOptions options) {
14+
final db = super.open(options);
1615

1716
db.createFunction(
1817
functionName: 'sleep',

example/linux_cli_example.dart

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:async';
21
import 'dart:ffi';
32

43
import 'package:sqlite3/common.dart';
@@ -17,7 +16,7 @@ class TestOpenFactory extends DefaultSqliteOpenFactory {
1716
this.sqlitePath = defaultSqlitePath});
1817

1918
@override
20-
FutureOr<CommonDatabase> open(SqliteOpenOptions options) async {
19+
CommonDatabase open(SqliteOpenOptions options) {
2120
// For details, see:
2221
// https://pub.dev/packages/sqlite3#manually-providing-sqlite3-libraries
2322
sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.linux, () {

lib/src/common/abstract_open_factory.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class SqliteOpenFactory<Database extends sqlite.CommonDatabase> {
1515
String get path;
1616

1717
/// Opens a direct connection to the SQLite database
18-
FutureOr<Database> open(SqliteOpenOptions options);
18+
Database open(SqliteOpenOptions options);
1919

2020
/// Opens an asynchronous [SqliteConnection]
2121
FutureOr<SqliteConnection> openConnection(SqliteOpenOptions options);
@@ -77,14 +77,14 @@ abstract class AbstractDefaultSqliteOpenFactory<
7777
@protected
7878

7979
/// Opens a direct connection to a SQLite database connection
80-
FutureOr<Database> openDB(SqliteOpenOptions options);
80+
Database openDB(SqliteOpenOptions options);
8181

8282
@override
8383

8484
/// Opens a direct connection to a SQLite database connection
8585
/// and executes setup pragma statements to initialize the DB
86-
FutureOr<Database> open(SqliteOpenOptions options) async {
87-
var db = await openDB(options);
86+
Database open(SqliteOpenOptions options) {
87+
var db = openDB(options);
8888

8989
// Pragma statements don't have the same BUSY_TIMEOUT behavior as normal statements.
9090
// We add a manual retry loop for those.

lib/src/native/database/native_sqlite_connection_impl.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void _sqliteConnectionIsolate(_SqliteConnectionParams params) async {
264264
await client.post(const InitDb());
265265
}
266266

267-
final db = await params.openFactory.open(SqliteOpenOptions(
267+
final db = params.openFactory.open(SqliteOpenOptions(
268268
primaryConnection: params.primary, readOnly: params.readOnly));
269269

270270
runZonedGuarded(() async {

lib/src/web/web_sqlite_open_factory.dart

+4-13
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,10 @@ class DefaultSqliteOpenFactory
3434

3535
@override
3636

37-
/// It is possible to open a CommonDatabase in the main Dart/JS context with standard sqlite3.dart,
38-
/// This connection requires an external Webworker implementation for asynchronous operations.
39-
/// Do not use this in conjunction with async connections provided by Drift
40-
Future<CommonDatabase> openDB(SqliteOpenOptions options) async {
41-
final wasmSqlite = await WasmSqlite3.loadFromUrl(
42-
Uri.parse(sqliteOptions.webSqliteOptions.wasmUri));
43-
44-
wasmSqlite.registerVirtualFileSystem(
45-
await IndexedDbFileSystem.open(dbName: path),
46-
makeDefault: true,
47-
);
48-
49-
return wasmSqlite.open(path);
37+
/// This is currently not supported on web
38+
CommonDatabase openDB(SqliteOpenOptions options) {
39+
throw UnimplementedError(
40+
'Direct access to CommonDatabase is not available on web.');
5041
}
5142

5243
@override

pubspec.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ repository: https://github.com/powersync-ja/sqlite_async.dart
55
environment:
66
sdk: ">=3.4.0 <4.0.0"
77

8+
topics:
9+
- sqlite
10+
- async
11+
- sql
12+
- flutter
13+
814
dependencies:
15+
sqlite3: "^2.4.4"
916
sqlite3_web: ^0.1.2-wip
10-
sqlite3: ^2.4.4
1117
async: ^2.10.0
1218
collection: ^1.17.0
1319
mutex: ^3.1.0

test/utils/native_test_utils.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class TestSqliteOpenFactory extends TestDefaultSqliteOpenFactory {
2121
initStatements});
2222

2323
@override
24-
FutureOr<CommonDatabase> open(SqliteOpenOptions options) async {
24+
CommonDatabase open(SqliteOpenOptions options) {
2525
sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.linux, () {
2626
return DynamicLibrary.open(sqlitePath);
2727
});
28-
final db = await super.open(options);
28+
final db = super.open(options);
2929

3030
db.createFunction(
3131
functionName: 'test_sleep',

0 commit comments

Comments
 (0)