Skip to content

Commit

Permalink
Apply statement fix to web, prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
simolus3 committed Mar 10, 2023
1 parent 2522ce6 commit 06db2cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion sqlite3/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.9.3-dev
## 1.9.3

- Provide more information about the source of sqlite exceptions.
- Fix prepared statements without parameters not being reused properly.

## 1.9.2

Expand Down
14 changes: 8 additions & 6 deletions sqlite3/lib/src/wasm/statement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WasmFinalizableStatement extends FinalizablePart {
final WasmBindings bindings;

final List<Pointer> _allocatedWhileBinding = [];
var _variablesBound = false;
var _inResetState = true;
var _closed = false;

WasmFinalizableStatement(this.statement, this.bindings);
Expand All @@ -28,9 +28,9 @@ class WasmFinalizableStatement extends FinalizablePart {
}

void _reset() {
if (_variablesBound) {
if (!_inResetState) {
bindings.sqlite3_reset(statement);
_variablesBound = false;
_inResetState = true;
}

for (final pointer in _allocatedWhileBinding) {
Expand Down Expand Up @@ -85,6 +85,7 @@ class WasmStatement extends CommonPreparedStatement {
void _execute() {
int result;

finalizable._inResetState = false;
// Users should be able to execute statements returning rows, so we should
// call _step() to skip past rows.
do {
Expand Down Expand Up @@ -152,7 +153,6 @@ class WasmStatement extends CommonPreparedStatement {
}

_latestArguments = params;
finalizable._variablesBound = true;
}

void _bindMapParams(Map<String, Object?> params) {
Expand Down Expand Up @@ -193,7 +193,6 @@ class WasmStatement extends CommonPreparedStatement {
}

_latestArguments = paramsAsList;
finalizable._variablesBound = true;
}

void _bindParam(Object? param, int i) {
Expand Down Expand Up @@ -306,6 +305,7 @@ class WasmStatement extends CommonPreparedStatement {
final names = _columnNames;
final columnCount = names.length;
final rows = <List<Object?>>[];
finalizable._inResetState = false;

int resultCode;
while ((resultCode = _step()) == SqlError.SQLITE_ROW) {
Expand Down Expand Up @@ -341,7 +341,9 @@ class _ActiveCursorIterator extends IteratingCursor {
List<String> columnNames,
List<String?>? tableNames,
) : columnCount = columnNames.length,
super(columnNames, tableNames);
super(columnNames, tableNames) {
statement.finalizable._inResetState = false;
}

@override
bool moveNext() {
Expand Down
2 changes: 1 addition & 1 deletion sqlite3/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sqlite3
description: Provides lightweight yet convenient bindings to SQLite by using dart:ffi
version: 1.9.3-dev
version: 1.9.3
homepage: https://github.com/simolus3/sqlite3.dart/tree/main/sqlite3
issue_tracker: https://github.com/simolus3/sqlite3.dart/issues

Expand Down

0 comments on commit 06db2cf

Please sign in to comment.