Union.list() behavior inconsistent with normal queries

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

Bug Description

Union.list() returns an empty list in case of no results while normal queries return null. The two should behave the same.

Revision history for this message
cowwoc (gili) wrote :

My mistake. The Union was returning a list of size 1 where the nested element was an empty list. Closing this bug as invalid.

Changed in querydsl:
status: New → Invalid
Revision history for this message
cowwoc (gili) wrote :

On second thought, I think the original bug report is still valid. When the union returns no rows, list() returns a list of size 1 containing an empty list instead of returning null.

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

Can you given me an example code snippet of such a query? I couldn't replicate this as a test :

    @Test
    public void Union_Empty_Result() throws SQLException {
        SubQueryExpression<Integer> sq1 = sq().from(employee).where(employee.firstname.eq("XXX")).unique(employee.id);
        SubQueryExpression<Integer> sq2 = sq().from(employee).where(employee.firstname.eq("YYY")).unique(employee.id);
        List<Integer> list = query().union(sq1, sq2).list();
        assertTrue(list.isEmpty());
    }

list() should never return null

Revision history for this message
cowwoc (gili) wrote :

My mistake, I was confusing uniqueResult() with list(). The former returns null on no match, the latter returns an empty list. I agree with the current behavior. Closing this issue as INVALID.

Changed in querydsl:
status: New → Invalid
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.