Skip to content

Commit

Permalink
Fix missing query method in transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
cachapa committed Mar 3, 2024
1 parent 502d4a9 commit 9502060
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
## 3.0.0+1

- Fix missing `query` method in transactions

## 3.0.0

Major performance refactor with a few breaking changes.
Major performance refactor with a few breaking changes

- Change how tables and primary keys are fetched to minimize reads.
- Allow for more efficient bulk writing in underlying implementation.
- Rework abstractions to allow exposing Sqlite batches.
- Rename classes to better reflect their goals.
- Correctly identify and forbid semicolon separated statements.
- Change how tables and primary keys are fetched to minimize reads
- Allow for more efficient bulk writing in underlying implementation
- Rework abstractions to allow exposing Sqlite batches
- Rename classes to better reflect their goals
- Correctly identify and forbid semicolon separated statements

## 2.1.7

Expand Down
24 changes: 19 additions & 5 deletions lib/src/crdt_executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import 'database_api.dart';
final _sqlEngine = SqlEngine();

/// Intercepts CREATE TABLE queries to assist with table creation and updates.
/// Does not affect any other query types.
class CrdtTableExecutor {
/// Does not impact any other query types.
class CrdtTableExecutor extends _CrdtTableExecutor {
CrdtTableExecutor(ReadWriteApi super._db);

Future<List<Map<String, Object?>>> query(String sql, [List<Object?>? args]) =>
(_db as ReadWriteApi).query(sql, args);
}

class _CrdtTableExecutor {
final WriteApi _db;

CrdtTableExecutor(this._db);
_CrdtTableExecutor(this._db);

/// Executes a SQL query with an optional [args] list.
/// Use "?" placeholders for parameters to avoid injection vulnerabilities:
Expand Down Expand Up @@ -93,13 +100,20 @@ class CrdtTableExecutor {
}
}

class CrdtExecutor extends CrdtTableExecutor {
class CrdtExecutor extends CrdtWriteExecutor {
CrdtExecutor(ReadWriteApi super._db, super.hlc);

Future<List<Map<String, Object?>>> query(String sql, [List<Object?>? args]) =>
(_db as ReadWriteApi).query(sql, args);
}

class CrdtWriteExecutor extends _CrdtTableExecutor {
final Hlc hlc;
late final _hlcString = hlc.toString();

final affectedTables = <String>{};

CrdtExecutor(super._db, this.hlc);
CrdtWriteExecutor(super._db, this.hlc);

@override
Future<void> _executeStatement(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sql_crdt
description: Base package for Conflict-free Replicated Data Types (CRDTs) using SQL databases
version: 3.0.0
version: 3.0.0+1
homepage: https://github.com/cachapa/sql_crdt
repository: https://github.com/cachapa/sql_crdt
issue_tracker: https://github.com/cachapa/sql_crdt/issues
Expand Down

0 comments on commit 9502060

Please sign in to comment.