From f985244195ae304e56b2048adbed4fd57b2593cd Mon Sep 17 00:00:00 2001 From: lukaseder Date: Thu, 4 Jun 2015 00:16:21 +0200 Subject: [PATCH] [#4360] DSL.timestamp() generates wrong output in SQLite --- jOOQ/src/main/java/org/jooq/impl/DateOrTime.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/DateOrTime.java b/jOOQ/src/main/java/org/jooq/impl/DateOrTime.java index 1bceb5989d..8063ebdc3f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DateOrTime.java +++ b/jOOQ/src/main/java/org/jooq/impl/DateOrTime.java @@ -40,6 +40,8 @@ */ package org.jooq.impl; +import static org.jooq.impl.DSL.keyword; + import java.sql.Date; import java.sql.Time; @@ -77,13 +79,23 @@ class DateOrTime extends AbstractFunction { @Override final QueryPart getFunction0(Configuration configuration) { - switch (configuration.dialect().family()) { + switch (configuration.family()) { case MYSQL: case MARIADB: return DSL.field("{" + name(getDataType()) + "}({0})", getDataType(), field); + case SQLITE: { + String name = + getDataType().getType() == Date.class + ? "date" + : getDataType().getType() == Time.class + ? "time" + : "datetime"; + + return DSL.field("{0}({1})", getDataType(), keyword(name), field); + } + default: - case H2: return field.cast(getDataType()); } }