Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for upsert

See original GitHub issue

Is there already a way to execute upsert queries (update if a value exists, insert it otherwise)?

In SQLite and PostgreSQL, this is done with ON CONFLICT DO UPDATE:

MySQL does it a bit differently:

I’m not sure how feasible this is, I guess for now we’ll have to use transactions.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

juanluispazcommented, Mar 20, 2022

Release ts-sql-query 1.26.0 with support to “insert on conflict do nothing” and “insert on conflict do update” on PostgreSql, Sqlite, MariaDB and MySql.

See documentation here

threema-danilocommented, Mar 21, 2022

I used onConflictOn / doUpdateSet and it works perfectly. Thanks for the quick feature release! In case we run into any issues, I’ll let you know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upsert in SQL: What is an upsert, and when should you use ...
The UPSERT command in CockroachDB performs an upsert based on the uniqueness of the primary key column or columns, and it will perform...
Read more >
UPSERT - PostgreSQL wiki
"UPSERT" is a DBMS feature that allows a DML statement's author to atomically either insert a row, or on the basis of the...
Read more >
PostgreSQL Upsert Using INSERT ON CONFLICT statement
This tutorial shows you how to use the PostgreSQL upsert feature to insert or update data if the row that is being inserted...
Read more >
How to Add Upsert Support to Your API -
An upsert is an insert statement augmented with additional logic that ensures the new row will be updated if it already exists.
Read more >
Bulk upsert with lock · CREATE a TEMPORARY table · COPY or bulk-insert the new data into the temp table · LOCK the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found