Request: from(subQueryExpression, path) for alias

Bug #684636 reported by rrmckinley
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Medium
Unassigned

Bug Description

Sometimes I like to select from a sub query first and left join to it. There is not a way to do that in Querydsl. I currently have to select from a throwaway table and inner join to the sub query and then proceed with my left join.

Because of the method signature on from(), this feature would have to keep a reference to the previous argument. If the even arguments are alias paths and the odd arguments are SubQueryExpression or Expressions, then all is well. If there are two alias paths in a row or the first argument is an alias path, perhaps throw and exception.

Thanks,

McKinley

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

Thanks for the bug report. I will consider this addition.

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

McKinley, could you provide an example SQL SELECT query which should be supported by Querydsl SQL?

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

I added the feature to SVN trunk. Here are two unit tests that demonstrate it :

    @Test
    public void SubQuery_with_Alias(){
        List<Integer> ids1 = query().from(employee).list(employee.id);
        List<Integer> ids2 = query().from(sq().from(employee).list(employee.id), employee).list(employee.id);
        assertEquals(ids1, ids2);
    }

    @Test
    public void SubQuery_with_Alias2(){
        List<Integer> ids1 = query().from(employee).list(employee.id);
        List<Integer> ids2 = query().from(sq().from(employee).list(employee.id).as(employee)).list(employee.id);
        assertEquals(ids1, ids2);
    }

The second option was already available before. Could you confirm if this solution is sufficient?

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

Released in 2.0.6

Changed in querydsl:
status: Fix Committed → Fix Released
Revision history for this message
rrmckinley (rrmckinley) wrote :

Thank you. It helps having similar method signatures between from() and innerJoin(), leftJoin().

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.