Skip to content

Update thinks I'm changing a partition key when I'm not, in very narrow circumstances #261

@aethertap

Description

@aethertap

When I try to update non-partition-key fields in a table that has a partition key, and the update query includes a WHERE EXISTS... clause, I get the error message about not supporting update on partition keys. This isn't blocking my development and it seems very... specific, but I do think it's incorrect behavior so I wanted to mention it here.

Here is the smallest reproduction code I could come up with (I tested it with the vec0.so from sqlite-vec-0.1.7-alpha.9)

.load ./vec0

CREATE TABLE images (id INTEGER PRIMARY KEY, orphaned_ts INTEGER);
INSERT INTO images VALUES (1, NULL), (2, 1234567890);

CREATE VIRTUAL TABLE embeddings USING vec0 (
  id INTEGER PRIMARY KEY NOT NULL,
  image_id INTEGER,
  is_orphaned INTEGER NOT NULL,
  image_kind INTEGER PARTITION KEY,
  embedding_vector float[4] distance_metric=cosine
);

INSERT INTO embeddings (image_id, is_orphaned, image_kind, embedding_vector)
VALUES (1, 0, 1, vec_f32(zeroblob(16)));
INSERT INTO embeddings (image_id, is_orphaned, image_kind, embedding_vector)
VALUES (2, 0, 1, vec_f32(zeroblob(16)));

-- Works:
UPDATE embeddings SET is_orphaned = 0 WHERE is_orphaned = 1;

-- Fails with "UPDATE on partition key columns are not supported yet"
-- even though is_orphaned is not the partition key:
UPDATE embeddings SET is_orphaned = 0
WHERE is_orphaned = 0
AND EXISTS (SELECT 1 FROM images WHERE embeddings.image_id = images.id);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions