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

force deleteFrom argument to be a source table #37

Closed
bertlebee opened this issue May 30, 2020 · 0 comments · Fixed by #44
Closed

force deleteFrom argument to be a source table #37

bertlebee opened this issue May 30, 2020 · 0 comments · Fixed by #44

Comments

@bertlebee
Copy link
Contributor

users may only delete from a source table, not a joined table.

val basicDelete = deleteFrom(users).where(fName === "Fred") //valid
val joinDelete = deleteFrom((orders join users).on(fkUserId === userId)).where(fName === "Fred") //not valid but compiles

All major dialects provide some way to delete from a joined table but the table to be deleted from needs to be explicitly provided. We could specify a "zio-sql" way of doing this (with dialect specific implementations) e.g. I'd suggest

delete(orders).from((orders join users).on(fkUserId === userId)).where(fName === "Fred")

or we could just disallow this and let the dialect specific modules introduce the concept of deleting from a join in a manner similar to the dialect of choice (e.g. using for postgres)

@jdegoes do you have any preference here?

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.

1 participant