On 2020/01/08 2:00 AM, Michael Kappert wrote:
-- Modify one parent entry of foreign key fk_t1_id
REPLACE INTO T1 (ID, NAME) VALUES ('A', 'line 1-new');
------------------------------------------------------------------------

If I understand correctly, the upsert should behave like UPDATE in the
examples above, but it behaves like a DELETE followed by INSERT instead?


You say "upsert" but the operation in question is not an "upsert", it's a REPLACE which is really a DELETE followed by an INSERT, which is why you are seeing the behaviour you noted.

To do an actual UPSERT in SQLite, use the UPSERT method, which will look somewhat like this for your example:

INSERT INTO t1(id, name) VALUES ('A', 'line 1-new')
  ON CONFLICT (id) DO UPDATE SET name = excluded.name

;


HTH and Good luck,
Ryan
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to