Actions
Bug #1479
open[Wt::Dbo] [PostgresSQL] ptr.modify() : clear on collection
Start date:
10/16/2012
Due date:
% Done:
0%
Estimated time:
Description
Hello,
The method .clear() doesn't provide a correct SQL query to delete a complete collection for postgres SQL.
It provides :
delete from "FIRST_TABLE"
join "SECOND_TABLE" on "SECOND_TABLE"."ID_IN_SECOND_TABLE" = "FIRST_TABLE"."ID_IN_FIRST_TABLE"
where "SECOND_TABLE"."ID_IN_SECOND_TABLE" = idToDelete;
As you can see in the postgres documentation DELETE doesn't accept JOIN.
http://docs.postgresqlfr.org/9.0/sql-delete.html
It should be :
DELETE FROM "FIRST_TABLE"
USING "SECOND_TABLE"
WHERE "SECOND_TABLE"."ID_IN_SECOND_TABLE" = "FIRST_TABLE"."ID_IN_FIRST_TABLE"
AND "SECOND_TABLE"."ID_IN_SECOND_TABLE" = idToDelete;
Regards,
Thomas
Updated by Koen Deforche about 12 years ago
- Status changed from New to InProgress
- Assignee set to Koen Deforche
Hey Thomas,
We're learning something new everyday. I'ld prefer the 'standard' syntax in this case, which is using a nested query.
I hope you can work around this problem using a manual Session::execute() (and that I can make this 'Normal' priority) ?
Regards,
koen
Updated by Thomas Saquet about 12 years ago
Hey Koen,
Sure, i can do that, thank you. Indeed the priority becomes 'normal' :)
Regards,
Thomas
Updated by Koen Deforche about 12 years ago
- Priority changed from High to Normal
Updated by Koen Deforche almost 10 years ago
Some notes:
- In general, it's too complicated, or even impossible (what if you join many tables, what is it that you actually should delete?)
- We should change the documentation to say this only works for simple queries.
Actions