Project

General

Profile

Actions

Bug #1479

open

[Wt::Dbo] [PostgresSQL] ptr.modify() : clear on collection

Added by Thomas Saquet about 12 years ago. Updated almost 10 years ago.

Status:
InProgress
Priority:
Normal
Assignee:
Target version:
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

Actions #1

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

Actions #2

Updated by Thomas Saquet about 12 years ago

Hey Koen,

Sure, i can do that, thank you. Indeed the priority becomes 'normal' :)

Regards,

Thomas

Actions #3

Updated by Koen Deforche about 12 years ago

  • Priority changed from High to Normal
Actions #4

Updated by Koen Deforche about 10 years ago

  • Target version set to 3.3.4
Actions #5

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

Also available in: Atom PDF