You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
After assigning table.data directly, INSERT stores duplicate keys and DELETE throws #2715
When rows are put into a table with a PRIMARY KEY by assigning alasql.tables.t.data (a documented way to load data fast), the key index stays empty. UPDATE rebuilds it since #2341, but INSERT and DELETE do not:
alasql('CREATE TABLE pk1 (id INT PRIMARY KEY, v INT)');alasql.tables.pk1.data=[{id: 1,v: 1},{id: 2,v: 2}];alasql('INSERT INTO pk1 VALUES (1, 99)');// 1: a second row with id 1 is storedalasql('DELETE FROM pk1 WHERE id = 1');// Error: Something wrong with primary key index on table
Measured on develop (94ccf84). UNIQUE keys behave the same way.
Direction
Rebuild the key indexes in one place that INSERT, UPDATE and DELETE all pass through, when the data no longer matches the index (for example when table.data has been replaced), instead of in the UPDATE path only. A duplicate key that gets stored and a DELETE that throws are wrong results, so this can go into 4.x.
Activity
Fix index for directly assigned table.data to close AlaSQL#2715 (AlaS…