[SQL] DML with a subquery.notExists() is generating a invalid statement
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
High
|
Unassigned |
Bug Description
I have a very simple test model with Person and Department, where person has a FK to department.
These are the Q-types:
QPerson p = QPerson.person;
QDepartment d = QDepartment.
The following command:
Is generating the following SQL:
delete from department
where not exists (select person
from person person
where person.
It seems there are 2 things wrong:
* The outer delete is not generating an alias, so the inner d.id is being translated as id alone, which is not right, and should be department.id
* The select person alone is invalid. Ideally, the .exists() and .notExists() would generate something like select 1 ...
Likewise, an update has the same error:
DB.
Generates (also missing alias and column on the select part):
update department
set name = 'AAA'
where not exists (select person
from person person
where person.
Changed in querydsl: | |
importance: | Undecided → High |
Thanks for the bug report. It is a bug in the path serialization for DML clauses. Apparently in subqueries the full path needs always to be used.