Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text primary key not supported in v0.1.6? #150

Open
a-h opened this issue Dec 6, 2024 · 1 comment
Open

Text primary key not supported in v0.1.6? #150

a-h opened this issue Dec 6, 2024 · 1 comment

Comments

@a-h
Copy link

a-h commented Dec 6, 2024

With this input:

create virtual table text_pk using vec0(
  pk text not null primary key,
  embedding float[3],
);

insert or replace into text_pk (pk, embedding) values ('a', '[1, 2, 3]');
insert or replace into text_pk (pk, embedding) values ('a', '[4, 5, 6]');

select rowid, pk, vec_to_json(embedding) from text_pk;

I expected one row with pk 'a' and embedding '[4, 5, 6]', but got:

+-------+----+------------------------------+
| rowid | pk | vec_to_json(embedding)       |
+-------+----+------------------------------+
| 1     | a  | [1.000000,2.000000,3.000000] |
+-------+----+------------------------------+
| 2     | a  | [4.000000,5.000000,6.000000] |
+-------+----+------------------------------+

Is this a bug?

@asg017
Copy link
Owner

asg017 commented Dec 9, 2024

This is a bug, an error should be thrown because not null is not supported in vec0 constructors yet.

Removing that should enforce primary keys:

create virtual table text_pk using vec0(
  pk text primary key,
  embedding float[3],
);

insert or replace into text_pk (pk, embedding) values ('a', '[1, 2, 3]');
insert or replace into text_pk (pk, embedding) values ('a', '[4, 5, 6]'); -- Runtime error: UNIQUE constraint failed on text_pk primary key

Though also keep in mind, insert or replace into is quite supported in vec0 virtual tables yet, see #127

So there are two bugs, one for incorrect parsing of primary keys when not null is defined, and a second one for upserts. I'll try to fix both this week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants