File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -45,14 +45,20 @@ class WebDatabase
45
45
Future <void > get isInitialized => initialize ();
46
46
47
47
@override
48
+
49
+ /// Not relevant for web.
48
50
Never isolateConnectionFactory () {
49
51
throw UnimplementedError ();
50
52
}
51
53
52
54
@override
55
+
56
+ /// Not supported on web. There is only 1 connection.
53
57
int get maxReaders => throw UnimplementedError ();
54
58
55
59
@override
60
+
61
+ /// Not relevant for web.
56
62
Never get openFactory => throw UnimplementedError ();
57
63
58
64
@override
@@ -209,6 +215,12 @@ class _ExclusiveTransactionContext extends _ExclusiveContext {
209
215
@override
210
216
Future <ResultSet > execute (String sql,
211
217
[List <Object ?> parameters = const []]) async {
218
+ // Operations inside transactions are executed with custom requests
219
+ // in order to verify that the connection does not have autocommit enabled.
220
+ // The worker will check if autocommit = true before executing the SQL.
221
+ // An exception will be thrown if autocommit is enabled.
222
+ // The custom request which does the above will return the ResultSet as a formatted
223
+ // JavaScript object. This is the converted into a Dart ResultSet.
212
224
return await wrapSqliteException (() async {
213
225
var res = await _database._database.customRequest (CustomDatabaseMessage (
214
226
CustomDatabaseMessageKind .executeInTransaction, sql, parameters));
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ import 'package:sqlite_async/sqlite3_common.dart';
8
8
9
9
import '../protocol.dart' ;
10
10
11
+ /// A base class for a web worker SQLite controller.
12
+ /// This returns an instance of [AsyncSqliteDatabase] which
13
+ /// can be extended to perform custom requests.
11
14
base class AsyncSqliteController extends DatabaseController {
12
15
@override
13
16
Future <WorkerDatabase > openDatabase (
@@ -26,6 +29,8 @@ base class AsyncSqliteController extends DatabaseController {
26
29
}
27
30
}
28
31
32
+ /// Worker database which handles custom requests. These requests are used for
33
+ /// handling exclusive locks for shared web workers and custom SQL execution scripts.
29
34
class AsyncSqliteDatabase extends WorkerDatabase {
30
35
@override
31
36
final CommonDatabase database;
You can’t perform that action at this time.
0 commit comments