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

Apply WHERE clause to INSERT SELECT .. ON CONFLICT #204

Open
jkachmar opened this issue Aug 26, 2020 · 0 comments
Open

Apply WHERE clause to INSERT SELECT .. ON CONFLICT #204

jkachmar opened this issue Aug 26, 2020 · 0 comments

Comments

@jkachmar
Copy link
Contributor

INSERT SELECT .. ON CONFLICT .. UPDATE is currently implemented as insertSelectWithConflict, which provides basic upsert functionality in a fairly nice way.

Unfortunately it's fairly limited compared to Esqueleto's update in that it's not possible to constrain what gets updated with a where_ clause.

The current insertSelectWithConflict is nice in that the third argument has the signature:

(SqlExpr (Entity val) -> SqlExpr (Entity val) -> [SqlExpr (Update val)])

...which provides a concrete list of updates, which can be used to choose between DO NOTHING or DO UPDATE when the SQL is being generated.


I'm mostly opening this issue up so that interested parties can discuss and/or propose a good API for this. From what I've poked around with so far, everything has small compromises in terms of ergonomics or type safety.


Related issues/PRs: #131 #155

@jkachmar jkachmar changed the title Apply WHERE clause to INSERT SELECT .. ON CONFLICT .. UPDATE Apply WHERE clause to INSERT SELECT .. ON CONFLICT Aug 26, 2020
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

No branches or pull requests

1 participant