From 3128345a7458995c3cab85aa5f24082d6db1c7c7 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Mon, 27 Feb 2023 16:59:35 +0100 Subject: [PATCH] [jOOQ/jOOQ#14437] Get this to work on H2 as well --- jOOQ/src/main/java/org/jooq/impl/Convert.java | 19 +++++++++++++++++++ .../src/main/java/org/jooq/tools/Convert.java | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/impl/Convert.java b/jOOQ/src/main/java/org/jooq/impl/Convert.java index d65117ff23..47e021cebe 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Convert.java +++ b/jOOQ/src/main/java/org/jooq/impl/Convert.java @@ -102,6 +102,7 @@ import org.jooq.Field; import org.jooq.JSON; import org.jooq.JSONB; import org.jooq.JSONFormat; +import org.jooq.Param; import org.jooq.QualifiedRecord; import org.jooq.Record; import org.jooq.Result; @@ -1125,6 +1126,15 @@ final class Convert { if (r != null) return (U) r; + // If that failed, try the H2 specific format + if (((String) from).startsWith("INTERVAL")) { + try { + r = ((Param) scope.dsl().parser().parseField((String) from)).getValue(); + return (U) r; + } + catch (Exception ignore) {} + } + // If that failed, try the PostgreSQL specific formats try { return (U) PostgresUtils.toYearToMonth(from); @@ -1140,6 +1150,15 @@ final class Convert { if (r != null) return (U) r; + // If that failed, try the H2 specific format + if (((String) from).startsWith("INTERVAL")) { + try { + r = ((Param) scope.dsl().parser().parseField((String) from)).getValue(); + return (U) r; + } + catch (Exception ignore) {} + } + // If that failed, try the PostgreSQL specific formats try { return (U) PostgresUtils.toDayToSecond(from); diff --git a/jOOQ/src/main/java/org/jooq/tools/Convert.java b/jOOQ/src/main/java/org/jooq/tools/Convert.java index 9c80b1db0e..878a7fb71b 100644 --- a/jOOQ/src/main/java/org/jooq/tools/Convert.java +++ b/jOOQ/src/main/java/org/jooq/tools/Convert.java @@ -100,6 +100,7 @@ import org.jooq.EnumType; import org.jooq.Field; import org.jooq.JSON; import org.jooq.JSONB; +import org.jooq.Param; import org.jooq.QualifiedRecord; import org.jooq.Record; import org.jooq.Result; @@ -1069,6 +1070,15 @@ public final class Convert { if (r != null) return (U) r; + // If that failed, try the H2 specific format + if (((String) from).startsWith("INTERVAL")) { + try { + r = ((Param) scope.dsl().parser().parseField((String) from)).getValue(); + return (U) r; + } + catch (Exception ignore) {} + } + // If that failed, try the PostgreSQL specific formats try { return (U) PostgresUtils.toYearToMonth(from); @@ -1084,6 +1094,15 @@ public final class Convert { if (r != null) return (U) r; + // If that failed, try the H2 specific format + if (((String) from).startsWith("INTERVAL")) { + try { + r = ((Param) scope.dsl().parser().parseField((String) from)).getValue(); + return (U) r; + } + catch (Exception ignore) {} + } + // If that failed, try the PostgreSQL specific formats try { return (U) PostgresUtils.toDayToSecond(from);