Skip to content

Commit

Permalink
Merge pull request #45 from powersync-ja/fix-remove
Browse files Browse the repository at this point in the history
Revert optimization breaking deletes
  • Loading branch information
rkistner authored Nov 8, 2024
2 parents cd6f12e + c6b8790 commit ebfbbef
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ inherits = "release"
inherits = "wasm"

[workspace.package]
version = "0.3.4"
version = "0.3.5"
edition = "2021"
authors = ["JourneyApps"]
keywords = ["sqlite", "powersync"]
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "co.powersync"
version = "0.3.4"
version = "0.3.5"
description = "PowerSync Core SQLite Extension"

repositories {
Expand Down
2 changes: 1 addition & 1 deletion android/src/prefab/prefab.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"name": "powersync_sqlite_core",
"schema_version": 2,
"dependencies": [],
"version": "0.3.4"
"version": "0.3.5"
}
15 changes: 8 additions & 7 deletions crates/core/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ FROM json_each(?) e",
// operations when last_applied_op = 0.
// We do still need to do the "supersede_statement" step for this case, since a REMOVE
// operation can supersede another PUT operation we're syncing at the same time.
let mut last_applied_op = bucket_statement.column_int64(1)?;
let mut is_empty = bucket_statement.column_int64(1)? == 0;

// Statement to supersede (replace) operations with the same key.
// language=SQLite
Expand Down Expand Up @@ -134,11 +134,12 @@ INSERT OR IGNORE INTO ps_updated_rows(row_type, row_id) VALUES(?1, ?2)",
add_checksum = add_checksum.wrapping_add(supersede_checksum);
op_checksum = op_checksum.wrapping_sub(supersede_checksum);

if superseded_op <= last_applied_op {
// Superseded an operation previously applied - we cannot skip removes
// For initial sync, last_applied_op = 0, so this is always false.
// For subsequent sync, this is only true if the row was previously
// synced, not when it was first synced in the current batch.
// Superseded an operation, only skip if the bucket was empty
// Previously this checked "superseded_op <= last_applied_op".
// However, that would not account for a case where a previous
// PUT operation superseded the original PUT operation in this
// same batch, in which case superseded_op is not accurate for this.
if !is_empty {
superseded = true;
}
}
Expand Down Expand Up @@ -225,7 +226,7 @@ WHERE bucket = ?1",
clear_statement2.exec()?;

add_checksum = 0;
last_applied_op = 0;
is_empty = true;
op_checksum = 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion powersync-sqlite-core.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'powersync-sqlite-core'
s.version = '0.3.4'
s.version = '0.3.5'
s.summary = 'PowerSync SQLite Extension'
s.description = <<-DESC
PowerSync extension for SQLite.
Expand Down
4 changes: 2 additions & 2 deletions tool/build_xcframework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function createXcframework() {
<key>MinimumOSVersion</key>
<string>11.0</string>
<key>CFBundleVersion</key>
<string>0.3.4</string>
<string>0.3.5</string>
<key>CFBundleShortVersionString</key>
<string>0.3.4</string>
<string>0.3.5</string>
</dict>
</plist>
EOF
Expand Down

0 comments on commit ebfbbef

Please sign in to comment.