Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RETURNING for SQLite #1885

Closed
bouk opened this issue Sep 28, 2023 · 1 comment · Fixed by #2070
Closed

Support RETURNING for SQLite #1885

bouk opened this issue Sep 28, 2023 · 1 comment · Fixed by #2070

Comments

@bouk
Copy link
Contributor

bouk commented Sep 28, 2023

@billy1624 I'm not sure what the original problem was, but could RETURNING be supported for SQLite now?

Motivation

I have a query that has an ON CONFLICT and I want to use exec_with_returning, however last_insert_rowid is not set for SQLite when there's a conflict, so there's no way to figure out which row was updated. My query looks like:

Model::insert().on_conflict(...).exec_with_returning(db)

This works fine on Postgres but not SQLite

Proposed Solutions

Get RETURNING working for SQLite

Current Workarounds

You can do an extra SELECT query instead of using ON CONFLICT

@tyt2y3
Copy link
Member

tyt2y3 commented Sep 29, 2023

I think the blocker is we needed a way to tell if the linked SQLite version supports RETURNING and adjust the logic accordingly on compile time.

A less ideal solution would be to detect that on runtime, and adjust the logic accordingly. This would actually be a bigger change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants