Querydsl-sql produced invalid SQL for fullJoin()

Bug #754743 reported by cowwoc on 2011-04-08
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.

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

Changed in querydsl:
status: New → Fix Committed

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  Edit
Everyone can see this information.

Other bug subscribers