In SQLite, suppose that we have the following table:
CREATE TABLE IF NOT EXISTS external_data (
name TEXT PRIMARY KEY NOT NULL,
atime TEXT NOT NULL,
content TEXT NOT NULL
);
And we have inserted a row:
INSERT INTO external_data
VALUES ("name", "october", "a");
Plus, we have executed an ‘upsert’ statement:
INSERT INTO external_data
VALUES ("name", "december", "b")
ON CONFLICT (name)
DO UPDATE SET content = "b"
AND atime = "december";
Without conflicts it does what you expect.
But we do have a conflict, and we end up with the following in the table:
sqlite> SELECT * FROM external_data ;
name|field|0
There’s an atime
field of value "0"
instead of "december"
.
What the hell is going on
Well, we misplaced the SET
separator ,
with AND
because having AND
in WHERE
makes sense and we casuall