Skip to content

Commit bad4183

Browse files
committed
chore(celest): Add logStatements parameter to connect
1 parent 988fb7e commit bad4183

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

packages/celest/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
## 1.0.5
1+
## 1.0.5-wip
22

33
- chore: Remove GCP mentions
44
- chore: Update analyzer plugin to v2 model
5+
- chore: Add `logStatements` parameter to `connect` method
56

67
## 1.0.4
78

packages/celest/lib/src/runtime/data/connect.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Future<Database> connect<Database extends GeneratedDatabase>(
2828
required secret tokenSecret,
2929
void Function(sqlite3.CommonDatabase)? setup,
3030
String? path,
31+
bool logStatements = false,
3132
}) async {
3233
final host = context.get(hostnameVariable);
3334
if (host == null) {
@@ -36,6 +37,7 @@ Future<Database> connect<Database extends GeneratedDatabase>(
3637
name: name,
3738
path: path,
3839
setup: setup,
40+
logStatements: logStatements,
3941
);
4042
return _checkConnection(factory(executor));
4143
}
@@ -54,9 +56,17 @@ Future<Database> connect<Database extends GeneratedDatabase>(
5456
final QueryExecutor connector;
5557
switch (hostUri) {
5658
case Uri(scheme: 'file', path: '/:memory:'):
57-
connector = await inMemoryExecutor(setup: setup);
59+
connector = await inMemoryExecutor(
60+
setup: setup,
61+
logStatements: logStatements,
62+
);
5863
case Uri(scheme: 'file', :final path):
59-
connector = await localExecutor(name: name, path: path, setup: setup);
64+
connector = await localExecutor(
65+
name: name,
66+
path: path,
67+
setup: setup,
68+
logStatements: logStatements,
69+
);
6070
case Uri(scheme: 'ws' || 'wss' || 'http' || 'https' || 'libsql'):
6171
final token = context.get(tokenSecret);
6272
if (token == null) {

packages/celest/lib/src/runtime/data/connect.io.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@ final Logger _logger = Logger('Celest.Data');
1212
/// A [QueryExecutor] for an in-memory database.
1313
Future<QueryExecutor> inMemoryExecutor({
1414
void Function(sqlite3.CommonDatabase)? setup,
15+
bool logStatements = false,
1516
}) async {
16-
return NativeDatabase.memory(setup: setup);
17+
return NativeDatabase.memory(setup: setup, logStatements: logStatements);
1718
}
1819

1920
/// A [QueryExecutor] with local persistence.
2021
Future<QueryExecutor> localExecutor({
2122
required String name,
2223
void Function(sqlite3.CommonDatabase)? setup,
2324
String? path,
25+
bool logStatements = false,
2426
}) async {
2527
if (path == null) {
2628
Uri? packageConfig;
@@ -34,7 +36,7 @@ Future<QueryExecutor> localExecutor({
3436
'Failed to determine package config path. '
3537
'Falling back to in-memory database.',
3638
);
37-
return inMemoryExecutor(setup: setup);
39+
return inMemoryExecutor(setup: setup, logStatements: logStatements);
3840
}
3941
path = p.join(
4042
p.dirname(p.fromUri(packageConfig)),
@@ -52,5 +54,6 @@ Future<QueryExecutor> localExecutor({
5254
cachePreparedStatements: true,
5355
enableMigrations: true,
5456
setup: setup,
57+
logStatements: logStatements,
5558
);
5659
}

packages/celest/lib/src/runtime/data/connect.web.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,24 @@ import 'package:sqlite3/wasm.dart';
66
/// A [QueryExecutor] for an in-memory database.
77
Future<QueryExecutor> inMemoryExecutor({
88
void Function(sqlite3.CommonDatabase)? setup,
9+
bool logStatements = false,
910
}) async {
1011
final sqlite3 = await WasmSqlite3.loadFromUrl(Uri.parse('./sqlite3.wasm'));
1112
sqlite3.registerVirtualFileSystem(InMemoryFileSystem(), makeDefault: true);
12-
return WasmDatabase.inMemory(sqlite3, setup: setup);
13+
return WasmDatabase.inMemory(
14+
sqlite3,
15+
setup: setup,
16+
logStatements: logStatements,
17+
);
1318
}
1419

1520
/// A [QueryExecutor] with local persistence.
1621
Future<QueryExecutor> localExecutor({
1722
required String name,
1823
void Function(sqlite3.CommonDatabase)? setup,
24+
bool logStatements = false,
1925
String? path,
2026
}) async {
2127
// TODO(dnys1): We don't have a use case for this yet.
22-
return inMemoryExecutor(setup: setup);
28+
return inMemoryExecutor(setup: setup, logStatements: logStatements);
2329
}

0 commit comments

Comments
 (0)