Open majdisorder opened 1 week ago
Upon further investigation I realized that sqlite actually has syntax for this. https://www.sqlite.org/lang_upsert.html
INSERT INTO my_table(id, col1, col2)
VALUES
('id1','value1', 1),
('id2','value2', 2),
('id3','value3', 3)
ON CONFLICT(id) DO
UPDATE SET
col1=excluded.col1,
col2=excluded.col2;
Is your feature request related to a problem? Please describe.
It would be nice to have an upsert function.
Describe the solution you'd like
Here is how I currently solved it in gdscript.
NOTE: it would make sense to replace the
ìd_col
parameter by aconditions
parameter to be more in line with other QOL functions likeselect_rows
andupdate_rows
EDIT: I just noticed the code above does not account for the fact that
id_col
may already be escaped or that the corresponding property inrow_data
may be escaped. That would be something to keep in mind.