mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-19 01:24:20 +01:00
The op_insert function was incorrectly trying to capture an "old record"
for fresh INSERT operations when a table had dependent materialized views.
This caused a "Cannot delete: no current row" error because the cursor
wasn't positioned on any row for new inserts.
The issue was introduced in commit f38333b3 which refactored the state
machine for incremental view handling but didn't properly distinguish
between:
- Fresh INSERT operations (no old record exists)
- UPDATE operations without rowid change (old record should be captured)
- UPDATE operations with rowid change (already handled by DELETE)
This fix checks if cursor.rowid() returns a value before attempting to
capture the old record. If no row exists (fresh INSERT), we correctly
set old_record to None instead of erroring out.
I am also including tests to make sure this doesn't break. The reason I
didn't include tests earlier is that I didn't know it was possible to
run the tests under a flag. But in here, I am just adding the flag to
the execution script.
18 lines
580 B
Bash
Executable File
18 lines
580 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Get the directory where this script is located
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# Go to the project root (one level up from scripts/)
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
TURSODB="$PROJECT_ROOT/target/debug/tursodb"
|
|
|
|
# Add experimental features for testing
|
|
EXPERIMENTAL_FLAGS="--experimental-views"
|
|
|
|
# if RUST_LOG is non-empty, enable tracing output
|
|
if [ -n "$RUST_LOG" ]; then
|
|
TESTING="true" "$TURSODB" -m list -q $EXPERIMENTAL_FLAGS -t testing/test.log "$@"
|
|
else
|
|
TESTING="true" "$TURSODB" -m list -q $EXPERIMENTAL_FLAGS "$@"
|
|
fi
|