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.

OUTPUT: PostgreSQL support (RETURNING clause)

See original GitHub issue

Using postgres I use “returning *” when inserting or updating data. This allows you to get not only the primary key but also all the fields. Is it possible to do this with linq2db?

I think in some cases this is more convenient than inserting data and then selecting them. If you use “returning *”, you get an atomic operation and you do not need to select the primary key type.

Something like

T obj = db.Insert<T>(T item);
T obj = db.Update<T>(T item);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
picolinocommented, Nov 29, 2020

Upvote for feature implementation

4reactions
sdanylivcommented, Jan 22, 2018

This feature is in our TODO list. After CTE feature, we will start implementing this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: 15: 6.4. Returning Data from Modified Rows
The INSERT , UPDATE , and DELETE commands all have an optional RETURNING clause that supports this. Use of RETURNING avoids performing an...
Read more >
Documentation: 15: INSERT
The optional RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted (or updated, if an ON CONFLICT...
Read more >
PostgreSQL - The RETURNING Clause - Programster's Blog
The RETURNING clause allows one to return the rows that one inserts, updates, or deletes. This is a really neat/useful feature as it...
Read more >
How to Use UPDATE RETURNING Clause in PostgreSQL
In PostgreSQL, the UPDATE RETURNING clause not only updates the selected rows but also retrieves the modified rows.
Read more >
The Postgres RETURNING clause
This clause allows us to change the output of the UPDATE query. So, instead you pre-fetching the IDs before updating, we can retrieve...
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