PostgreSQL gets very confused when date_part() is used in a GROUP BY and the part bit isn't a constant. It doesn't recognize the selected values as being identical to the grouped-by values, and throws an error. So we use a literal here.

This commit is contained in:
Par Winzell
2011-02-15 23:21:11 +00:00
parent 6603fb7d81
commit 10e97b55c9
@@ -87,8 +87,8 @@ public class PostgreSQLBuilder
@Override public Void visit (DatePart exp)
{
return appendFunctionCall(
"date_part", Exps.value(translateDatePart(exp.getPart())), exp.getArg());
String datePart = "'" + translateDatePart(exp.getPart()) + "'";
return appendFunctionCall("date_part", Exps.literal(datePart), exp.getArg());
}
@Override