Request: from(subQueryExpression, path) for alias

Bug #684636 reported by rrmckinley on 2010-12-03
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

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

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

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

Released in 2.0.6

Changed in querydsl:
status: Fix Committed → Fix Released
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  Edit
Everyone can see this information.

Other bug subscribers