.having(new FilterItem(new SelectItem(new MutableColumn("col2")), OperatorType.GREATER_THAN, 40))
.orderBy(new MutableColumn("bla"));
assertEquals("SELECT COUNT(*) FROM foobar WHERE foob IS NULL GROUP BY col1 HAVING col2 > 40 ORDER BY bla ASC",
q.toString());
AbstractQueryRewriter rewriter = new DefaultQueryRewriter(null) {
};
assertEquals("SELECT COUNT(*) FROM foobar WHERE foob IS NULL GROUP BY col1 HAVING col2 > 40 ORDER BY bla ASC",
rewriter.rewriteQuery(q));
rewriter = new DefaultQueryRewriter(null) {
@Override
protected String rewriteFromItem(Query query, FromItem item) {
return "mytable";
}
};
assertEquals("SELECT COUNT(*) FROM mytable WHERE foob IS NULL GROUP BY col1 HAVING col2 > 40 ORDER BY bla ASC",
rewriter.rewriteQuery(q));
q.getSelectClause().setDistinct(true);
assertEquals(
"SELECT DISTINCT COUNT(*) FROM mytable WHERE foob IS NULL GROUP BY col1 HAVING col2 > 40 ORDER BY bla ASC",
rewriter.rewriteQuery(q));
}