[SQL] MySQLQuery generates invalid SQL when mixing limit and for update
Bug #857336 reported by
Luis Fernando Planella Gonzalez
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Querydsl |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
When using a MySQLQuery with forUpdate() and limit(), Querydsl is generating the SQL statement in the wrong order:
SELECT ... FROM ... WHERE ... FOR UPDATE LIMIT ?.
This is invalid. The expected order is:
SELECT ... FROM ... WHERE ... LIMIT ? FOR UPDATE.
For example, the following code triggers the bug:
MySQLQuery query = new MySQLQuery(...);
query.from(
To post a comment you must log in.
After examining the sources, I saw that SQLTemplates. serializeModifi ers is invoked after invoking context. serialize( ), which adds the for update clause on the Position.END. AFTER_MODIFIERS or something like that?
The problem is that the modifiers (limit, in this case) are added after that.
Maybe there should be another Position.