-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Delete statements with joins not supported #16
Comments
Thanks for reporting, yes currently these cases are not supported in DELETE, INSERT and UPDATE statements, the main reason is that the join method is not supported in all db engines, for example in Postgres, so don't know what is the best way to handle this, maybe we can:
What do you think ? |
for the moment, I agree that we should mention this in the docs, could you open an issue there please, or I do it myself ? |
I will open the issue there later if I don't see it already. Yeah, I don't think making the implicit conversion is the way to go--I was just looking up the USING statement in postgres but I'd have to come back to that. In a local dev branch, I've started to build onto the UPDATE/INSERT for sqlserver compiler as well as add tests. I think since the library already just ignores the unsupported statement it can stay that way until someone finds a reason not to silently ignore it. |
Any updates on adding join to insert/update/delete. Eagerly waiting for it. Was looking for a solution for SQLServer. |
@punssoma
for the time being I suggest using subqueries something like // delete the books where with AuthorId = 1
db.Query("Books").WhereIn("Id", q => q.From("Books").Join("Authors").Where("Authors.Id", 1).Select("Id")) |
@ahmad-moussawi Thanks for the tip. |
I made a typo on the alias, sorry about that.
Does not support delete statement joins
I'll try and work on a PR for this if I can finish work sometime this next week. I can see where it goes wrong in the compiler.
Example simple use case; I have a couple more complex ones too:
Query as DELETE (broken):
new Query("dbo.Foo as foo") .Join("dbo.Bar as bar", "foo.FooId", "bar.FooId") .Where("bar.IsWorking", 0) .Delete()
Produces
DELETE FROM [dbo].[Foo] AS [foo] WHERE [bar].[IsWorking] = 0
The text was updated successfully, but these errors were encountered: