[jOOQ/jOOQ#14437] Get this to work on H2 as well

This commit is contained in:
Lukas Eder 2023-02-27 16:59:35 +01:00
parent 8039850d7c
commit 3128345a74
2 changed files with 38 additions and 0 deletions

View File

@ -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<YearToMonth>) 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<DayToSecond>) 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);

View File

@ -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<YearToMonth>) 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<DayToSecond>) 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);