question-mark
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.

cross-platform MERGE that leverages existing ON CONFLICT, etc. clauses within dialects

See original GitHub issue

Migrated issue, originally created by jek (@jek)

Implement generic MERGE, aka ‘upsert’. In ANSI, it looks like:

MERGE INTO table_name1 USING table_name2 ON (condition)
WHEN MATCHED THEN UPDATE SET column1 = value1 [column2 = value2 ...](,)
WHEN NOT MATCHED THEN INSERT columns VALUES (values) 

Dialect support differs pretty widely. A quick & likely inaccurate poll:

  • Oracle 9+ has a MERGE
  • t-sql 2008 has a MERGE, earlier can maybe do IF EXISTS(SELECT ...)
  • MySQL is limited to a key violation condition, and can do either INSERT ... ON DUPLICATE KEY UPDATE or REPLACE INTO, INSERT being preferable
  • SQLite is limited to a key violation condition, and has INSERT .. ON CONFLICT REPLACE

Issue Analytics

  • State:closed
  • Created 16 years ago
  • Comments:40 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zzzeekcommented, Oct 19, 2020
0reactions
dwtcommented, Oct 19, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

Towards cross-platform interoperability for machine-assisted ...
In this paper, we investigate cross-platform interoperability for natural language processing (NLP) and, in particular, annotation of ...
Read more >
Lucene™ Core News
Apache Lucene is a high-performance, full-featured text search engine library written entirely in Java. It is a technology suitable for nearly any application ......
Read more >
How to use `INSERT ON CONFLICT` to upsert data in ... - Prisma
The actual implementation within PostgreSQL uses the INSERT command with a special ON CONFLICT clause to specify what to do if the record...
Read more >
RFC 6020: YANG - A Data Modeling Language for the ...
Further information on Internet Standards is available in Section 2 of RFC 5741. Information about the current status of this document, any errata, ......
Read more >
Social media in peace mediation - UN Peacemaker
peace mediation, involving official representatives of conflict parties. It provides a snapshot of the current state of play in terms of the role...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found