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.

Complete INSERT and UPSERT operations support

See original GitHub issue

What

This issue will track design and implementation of various forms of INSERT operation including UPSERT but excluding bulk inserts and select into new table statements.

Why

Right now we lack support of some insert sub-clauses/variations that are requested by users from time to time. It makes sense perform upfront design and implement it step-by-step.

Initial plans for this feature was to add translation of merge API calls to upsert-based SQL for postgresql and mysql providers but after more detailed review it became clear that it is not possible:

  • UPSERT is less flexible compared to Merge API and it is not possible to implement it’s limitations using Merge API
  • UPSERT support not limited to MySql and PostgreSQL and supports also databases with native merge support

Related issues

  • #869 - generic issue for OUTPUT/RETURNING clause support for various DML operations including INSERT
  • #979 - generic issue for RETURNING clause support in PostgreSQL for various DML operations including INSERT
  • #1480 - original issue to add UPSERT support though MergeAPI
  • #2355 - similar to #1480 : emulation of merge using upsert
  • #2528 - INSERT ... ON CONFLICT DO NOTHING feature request

Designs

API Design

Implementation notes and not supported functionality

In general we are not planning to implement following functionality right now:

  • insert query options/hints as we have separate task for it (#2603)
  • some db-specific features, implemented by single database and not expected to be used a lot. Such stuff could be implemented on request

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
viceroypenguincommented, Oct 18, 2020

Question 1: For SQLite, how is the InsertWith() method different than int Insert<TSource, TTarget>(this IQueryable<TSource> source, ITable<TTarget> target, Expression<Func<TSource, TTarget>> setter) with an IQueryable<> that was created via .AsCte() (other than parameter order)?

0reactions
jordan-erismancommented, Jun 16, 2021

Is there any timeline for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

upsert vs update vs insert - apex
Using the upsert operation, you can either insert or update an existing record in one call. To determine whether a record already exists, ......
Read more >
What's the difference between INSERT, UPDATE, UPSERT ...
The INSERT option pushes the incoming records to the destination. The UPDATE option keeps track of the records being updated in the database...
Read more >
Adding Table Rows using INSERT and UPSERT
This topic provides examples on how to add table rows using the SQL for Oracle NoSQL Database INSERT and UPSERT statements. You use...
Read more >
What Is UPSERT and How To Use It in MySQL?
Being an atomic operation, MySQL UPSERT gets completed in a single step. For instance, for a new record, it triggers an INSERT command....
Read more >
What is an upsert, and when should you use one?
Upserts are useful for anyone who works with a database to know, but the term “upsert” might not even appear in your DBMS's...
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