From d0993b7496fdbc3440bfccc8a8cb574624bbf8dd Mon Sep 17 00:00:00 2001 From: Alex Garcia Date: Tue, 19 Nov 2024 15:21:33 -0800 Subject: [PATCH] unblock aux failures for now --- sqlite-vec.c | 16 ++++++++-------- tests/__snapshots__/test-auxiliary.ambr | 8 ++++---- tests/test-auxiliary.py | 5 ++++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/sqlite-vec.c b/sqlite-vec.c index 0e0d58a..bac77d2 100644 --- a/sqlite-vec.c +++ b/sqlite-vec.c @@ -8188,15 +8188,15 @@ int vec0Update_Insert(sqlite3_vtab *pVTab, int argc, sqlite3_value **argv, int v_type = sqlite3_value_type(v); if(v_type != SQLITE_NULL && (v_type != p->auxiliary_columns[auxiliary_key_idx].type)) { sqlite3_finalize(stmt); - rc = SQLITE_ERROR; + rc = SQLITE_CONSTRAINT; vtab_set_error( - pVTab, - "Auxiliary column type mismatch: The auxiliary column %.*s has type %s, but %s was provided.", - p->auxiliary_columns[auxiliary_key_idx].name_length, - p->auxiliary_columns[auxiliary_key_idx].name, - type_name(p->auxiliary_columns[auxiliary_key_idx].type), - type_name(v_type) - ); + pVTab, + "Auxiliary column type mismatch: The auxiliary column %.*s has type %s, but %s was provided.", + p->auxiliary_columns[auxiliary_key_idx].name_length, + p->auxiliary_columns[auxiliary_key_idx].name, + type_name(p->auxiliary_columns[auxiliary_key_idx].type), + type_name(v_type) + ); goto cleanup; } sqlite3_bind_value(stmt, 1 + 1 + auxiliary_key_idx, v); diff --git a/tests/__snapshots__/test-auxiliary.ambr b/tests/__snapshots__/test-auxiliary.ambr index eb84f0f..923e196 100644 --- a/tests/__snapshots__/test-auxiliary.ambr +++ b/tests/__snapshots__/test-auxiliary.ambr @@ -409,25 +409,25 @@ # --- # name: test_types.3 dict({ - 'error': 'OperationalError', + 'error': 'IntegrityError', 'message': 'Auxiliary column type mismatch: The auxiliary column aux_int has type INTEGER, but TEXT was provided.', }) # --- # name: test_types.4 dict({ - 'error': 'OperationalError', + 'error': 'IntegrityError', 'message': 'Auxiliary column type mismatch: The auxiliary column aux_float has type FLOAT, but TEXT was provided.', }) # --- # name: test_types.5 dict({ - 'error': 'OperationalError', + 'error': 'IntegrityError', 'message': 'Auxiliary column type mismatch: The auxiliary column aux_text has type TEXT, but INTEGER was provided.', }) # --- # name: test_types.6 dict({ - 'error': 'OperationalError', + 'error': 'IntegrityError', 'message': 'Auxiliary column type mismatch: The auxiliary column aux_blob has type BLOB, but INTEGER was provided.', }) # --- diff --git a/tests/test-auxiliary.py b/tests/test-auxiliary.py index 9f03cbd..02e478a 100644 --- a/tests/test-auxiliary.py +++ b/tests/test-auxiliary.py @@ -49,13 +49,15 @@ def test_types(db, snapshot): ) assert exec(db, "select * from v") == snapshot() INSERT = "insert into v(vector, aux_int, aux_float, aux_text, aux_blob) values (?, ?, ?, ?, ?)" - assert ( exec(db, INSERT, [b"\x11\x11\x11\x11", 1, 1.22, "text", b"blob"]) == snapshot() ) assert exec(db, "select * from v") == snapshot() + # TODO: integrity test transaction failures in shadow tables + db.commit() # bad types + db.execute("BEGIN") assert ( exec(db, INSERT, [b"\x11\x11\x11\x11", "not int", 1.2, "text", b"blob"]) == snapshot() @@ -66,6 +68,7 @@ def test_types(db, snapshot): ) assert exec(db, INSERT, [b"\x11\x11\x11\x11", 1, 1.2, 1, b"blob"]) == snapshot() assert exec(db, INSERT, [b"\x11\x11\x11\x11", 1, 1.2, "text", 1]) == snapshot() + db.execute("ROLLBACK") # NULLs are totally chill assert exec(db, INSERT, [b"\x11\x11\x11\x11", None, None, None, None]) == snapshot()