Querydsl-sql produced invalid SQL for fullJoin()

Bug #754743 reported by cowwoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

The following code sniplet generates invalid SQL code:

  QQueues q = QQueues.queues;
  QQueueDoctors qd = QQueueDoctors.queueDoctors;
  QAppointments a = QAppointments.appointments;
  List<Object[]> rows = session.query().from(q, qd, a).where(q.id.eq(queueId.getId())).
   fullJoin(qd).on(qd.queueId.eq(q.id)).fullJoin(a).on(a.queueId.eq(q.id)).
   list(q.name, qd.doctorId, a.id);

The generated SQL is missing "full join" before the "on" keyword:

SELECT QUEUES.NAME, QUEUE_DOCTORS.DOCTOR_ID, APPOINTMENTS.ID
FROM QUEUES QUEUES, QUEUE_DOCTORS QUEUE_DOCTORS, APPOINTMENTS APPOINTMENTS
ON QUEUE_DOCTORS.QUEUE_ID = QUEUES.ID AND APPOINTMENTS.QUEUE_ID = QUEUES.ID
WHERE QUEUES.ID = ? "; SQL statement:
select QUEUES.NAME, QUEUE_DOCTORS.DOCTOR_ID, APPOINTMENTS.ID
from QUEUES QUEUES, QUEUE_DOCTORS QUEUE_DOCTORS, APPOINTMENTS APPOINTMENTS
on QUEUE_DOCTORS.QUEUE_ID = QUEUES.ID and APPOINTMENTS.QUEUE_ID = QUEUES.ID
where QUEUES.ID = ?

The problem is that fullJoin() notices that from() already contains the tables being joined-on so it omits "full join". I've never really used SQL joins before so it's possible I'm missing something but I'm expecting querydsl-sql to prevent me from generating invalid SQL. Either the dsl should make it impossible or I should get some runtime exception from querydsl explaining what I did wrong.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

IllegalStateExceptions are now thrown in these cases. You need to use a different alias in your join.

Changed in querydsl:
status: New → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.2.0-beta4

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.