Does this issue reproduce with the latest release?
Yes
What did you do?
genji test_index.db
CREATE TABLE cars (name TEXT NOT NULL, color TEXT NOT NULL, price VARCHAR(128));
CREATE UNIQUE INDEX idx_cars_name_color ON cars(name, color);
INSERT INTO cars (name, color, price) VALUES ("Tesla", "Red", "100000");
{
"name": "Tesla",
"color": "Red",
"price": "100000"
}
UPDATE cars SET price = '500000' WHERE (name = 'Tesla' AND color = 'Red');
exit
genji test_index.db
UPDATE cars SET price = '777777' WHERE (name = 'Tesla' AND color = 'Red');
wrong index arity <- here I get an ERROR!
The same behavior is observed in the runnable program, not only in CLI.
The problem only occurs when you run it again on an already created database.
What version of Genji are you using?
Does this issue reproduce with the latest release?
Yes
What did you do?
The same behavior is observed in the runnable program, not only in CLI. The problem only occurs when you run it again on an already created database.
What did you expect to see?
Correct record update, no mistake.
What did you see instead?
Error: wrong index arity
What Go version and environment are you using?
go env
OutputCode research
In my research on the code, I came to the conclusion that this problem may be because when indexes loading from existing database https://github.com/genjidb/genji/blob/b9b312418718f6eb24f7fea5ce480aa133e526e3/internal/catalog/catalog.go#L73 their types are not filled https://github.com/genjidb/genji/blob/b9b312418718f6eb24f7fea5ce480aa133e526e3/internal/database/info.go#L90
In the case when the database is created for the first time, the types are successfully added when creating the index https://github.com/genjidb/genji/blob/b9b312418718f6eb24f7fea5ce480aa133e526e3/internal/catalog/catalog.go#L300