mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 08:46:49 +02:00
vec0Update_Delete_ClearMetadata's long-text branch runs a DELETE via sqlite3_step, which returns SQLITE_DONE (101) on success. The code checked for failure but never normalized the success case to SQLITE_OK. The function's epilogue returned SQLITE_DONE as-is, which the caller (vec0Update_Delete) treated as an error, aborting the DELETE scan and silently leaving rows behind. - Normalize rc to SQLITE_OK after successful sqlite3_step in ClearMetadata - Move sqlite3_finalize before the rc check (cleanup on all paths) - Add test_delete_by_metadata_with_long_text regression test - Update test_deletes snapshot (row 3 now correctly deleted) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
dfd8dc5290
commit
ee9bd2ba4d
3 changed files with 43 additions and 26 deletions
|
|
@ -265,6 +265,35 @@ def test_deletes(db, snapshot):
|
|||
assert vec0_shadow_table_contents(db, "v") == snapshot()
|
||||
|
||||
|
||||
def test_delete_by_metadata_with_long_text(db):
|
||||
"""Regression for https://github.com/asg017/sqlite-vec/issues/274.
|
||||
|
||||
ClearMetadata left rc=SQLITE_DONE after the long-text DELETE, which
|
||||
propagated as an error and silently aborted the DELETE scan.
|
||||
"""
|
||||
db.execute(
|
||||
"create virtual table v using vec0("
|
||||
" tag text, embedding float[4], chunk_size=8"
|
||||
")"
|
||||
)
|
||||
for i in range(6):
|
||||
db.execute(
|
||||
"insert into v(tag, embedding) values (?, zeroblob(16))",
|
||||
[f"long_text_value_{i}"],
|
||||
)
|
||||
for i in range(4):
|
||||
db.execute(
|
||||
"insert into v(tag, embedding) values (?, zeroblob(16))",
|
||||
[f"long_text_value_0"],
|
||||
)
|
||||
assert db.execute("select count(*) from v").fetchone()[0] == 10
|
||||
|
||||
# DELETE by metadata WHERE — the pattern from the issue
|
||||
db.execute("delete from v where tag = 'long_text_value_0'")
|
||||
assert db.execute("select count(*) from v where tag = 'long_text_value_0'").fetchone()[0] == 0
|
||||
assert db.execute("select count(*) from v").fetchone()[0] == 5
|
||||
|
||||
|
||||
def test_knn(db, snapshot):
|
||||
db.execute(
|
||||
"create virtual table v using vec0(vector float[1], name text, chunk_size=8)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue