mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-13 21:01:01 +08:00
Fix count with empty resultsets
This commit is contained in:
parent
dccc48d4a4
commit
fb505d0495
@ -482,10 +482,14 @@ public abstract class AbstractSQLQuery<Q extends AbstractSQLQuery<Q>> extends Pr
|
||||
|
||||
listeners.preExecute(context);
|
||||
rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
boolean hasResult = rs.next();
|
||||
listeners.executed(context);
|
||||
|
||||
return rs.getLong(1);
|
||||
if (hasResult) {
|
||||
return rs.getLong(1);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
onException(context, e);
|
||||
throw configuration.translate(queryString, constants, e);
|
||||
|
||||
@ -610,6 +610,16 @@ public class SelectBase extends AbstractBaseTest {
|
||||
employee.salary.avg());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Having_Count() {
|
||||
//Produces empty resultset https://github.com/querydsl/querydsl/issues/1055
|
||||
query().from(employee)
|
||||
.innerJoin(employee2)
|
||||
.groupBy(employee.id)
|
||||
.having(Wildcard.count.eq(4L))
|
||||
.listResults(employee.id, employee.firstname);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void IllegalUnion() throws SQLException {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user