From 061219bc577534ccc63e6b954fb4775e1c83e20c Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Thu, 22 Jul 2010 21:37:11 +0000 Subject: [PATCH] Postgres returns a timestamp from date_trunc, whereas MySQL returns a date from date(). We should probably just modify DateFuncs.date to return a date in both cases (perhaps with a separate DateFun.DateCast class), but for now it's easier to have MySQL return a timestamp as well. --- src/java/com/samskivert/depot/impl/MySQLBuilder.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/java/com/samskivert/depot/impl/MySQLBuilder.java b/src/java/com/samskivert/depot/impl/MySQLBuilder.java index cc1b4fc..84dff3b 100644 --- a/src/java/com/samskivert/depot/impl/MySQLBuilder.java +++ b/src/java/com/samskivert/depot/impl/MySQLBuilder.java @@ -90,7 +90,10 @@ public class MySQLBuilder public Void visit (DateTruncate exp) { // exp.getTruncation() is currently always DAY - return appendFunctionCall("date", exp.getArg()); + _builder.append(" cast("); + appendFunctionCall("date", exp.getArg()); + _builder.append(" as datetime)"); + return null; } protected String getDateFunction (Part part)