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

SQLite SaveChanges: Use RETURNING clause #24835

Closed
Tracked by #22950 ...
bricelam opened this issue May 4, 2021 · 3 comments · Fixed by #27573
Closed
Tracked by #22950 ...

SQLite SaveChanges: Use RETURNING clause #24835

bricelam opened this issue May 4, 2021 · 3 comments · Fixed by #27573
Assignees
Labels
area-perf area-save-changes area-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@bricelam
Copy link
Contributor

bricelam commented May 4, 2021

SQLite 3.35.0 added the RETURNING clause to INSERT, UPDATE, and DELETE statements. Currently, the update pipeline uses SQL like this to propagate changes...

INSERT INTO "Sample" ("MaxLengthProperty", "Name", "RowVersion", "AdditionalDetails_Name",
    "AdditionalDetails_Value", "Details_Name", "Details_Value")
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6);

SELECT "Unique_No"
FROM "Sample"
WHERE changes() = 1 AND "rowid" = last_insert_rowid();

...but it could be updated to this after the SQLitePCLRaw bundle is updated.

INSERT INTO "Sample" ("MaxLengthProperty", "Name", "RowVersion", "AdditionalDetails_Name",
    "AdditionalDetails_Value", "Details_Name", "Details_Value")
VALUES (@p0, @p1, @p2, @p3, @p4, @p5, @p6)
RETURNING "Unique_No";
@roji
Copy link
Member

roji commented May 4, 2021

This is just like PostgreSQL! 💘

If you want to steal the PG provider's update pipeline customizations: https://github.com/npgsql/efcore.pg/tree/main/src/EFCore.PG/Update/Internal.

@bricelam
Copy link
Contributor Author

bricelam commented May 4, 2021

They've been taking a lot of inspiration from PostgreSQL lately. They borrowed their UPSERT syntax too.

@roji
Copy link
Member

roji commented May 4, 2021

Oh nice... Hopefully we'll get around to adding UPSERT support too at some point...

@ajcvickers ajcvickers added this to the Backlog milestone May 7, 2021
@bricelam bricelam removed the blocked label May 24, 2021
@roji roji self-assigned this Mar 10, 2022
@roji roji modified the milestones: Backlog, 7.0.0 Mar 10, 2022
@roji roji added area-perf closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Mar 10, 2022
@ghost ghost closed this as completed in #27573 Mar 17, 2022
@roji roji changed the title SQLite SaveChanges: Use RETURNING clause SQLite SaveChanges: Use RETURNING clause for insertion Mar 17, 2022
@roji roji changed the title SQLite SaveChanges: Use RETURNING clause for insertion SQLite SaveChanges: Use RETURNING clause Mar 17, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview3 Mar 31, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview3, 7.0.0 Nov 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-perf area-save-changes area-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants