[jOOQ/jOOQ#7900] Added Db2 support
This commit is contained in:
parent
d4f6f26bfe
commit
1242fd6763
@ -43,6 +43,7 @@ package org.jooq;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.H2;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
|
||||
@ -44,12 +44,14 @@ import static org.jooq.DatePart.MICROSECOND;
|
||||
import static org.jooq.DatePart.MILLISECOND;
|
||||
import static org.jooq.DatePart.QUARTER;
|
||||
import static org.jooq.DatePart.YEAR;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.HSQLDB;
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.keyword;
|
||||
import static org.jooq.impl.Names.N_DATEDIFF;
|
||||
import static org.jooq.impl.Names.N_DAYS;
|
||||
import static org.jooq.impl.Names.N_DAYS_BETWEEN;
|
||||
import static org.jooq.impl.Names.N_STRFTIME;
|
||||
import static org.jooq.impl.Names.N_TIMESTAMPDIFF;
|
||||
@ -94,10 +96,6 @@ final class DateDiff<T> extends AbstractField<Integer> {
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
switch (p) {
|
||||
case DAY:
|
||||
ctx.visit(N_DATEDIFF).sql('(').visit(date1).sql(", ").visit(date2).sql(')');
|
||||
return;
|
||||
|
||||
case MILLENNIUM:
|
||||
case CENTURY:
|
||||
case DECADE:
|
||||
@ -110,6 +108,10 @@ final class DateDiff<T> extends AbstractField<Integer> {
|
||||
ctx.visit(monthDiff(p));
|
||||
return;
|
||||
|
||||
case DAY:
|
||||
ctx.visit(N_DATEDIFF).sql('(').visit(date1).sql(", ").visit(date2).sql(')');
|
||||
return;
|
||||
|
||||
case MILLISECOND:
|
||||
ctx.visit(new DateDiff<>(MICROSECOND, date1, date2).div(inline(1000)));
|
||||
return;
|
||||
@ -183,14 +185,9 @@ final class DateDiff<T> extends AbstractField<Integer> {
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
switch (p) {
|
||||
case DAY:
|
||||
// [#4481] Parentheses are important in case this expression is
|
||||
// placed in the context of other arithmetic
|
||||
ctx.sql('(').visit(date1).sql(" - ").visit(date2).sql(')');
|
||||
return;
|
||||
|
||||
case MILLENNIUM:
|
||||
case CENTURY:
|
||||
case DECADE:
|
||||
@ -203,6 +200,19 @@ final class DateDiff<T> extends AbstractField<Integer> {
|
||||
ctx.visit(monthDiff(p));
|
||||
return;
|
||||
|
||||
case DAY:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// [#4481] Parentheses are important in case this expression is
|
||||
// placed in the context of other arithmetic
|
||||
ctx.sql('(').visit(date1).sql(" - ").visit(date2).sql(')');
|
||||
return;
|
||||
|
||||
case HOUR:
|
||||
case MINUTE:
|
||||
ctx.visit(partDiff(EPOCH).div(p == HOUR ? inline(3600) : inline(60)));
|
||||
@ -215,7 +225,7 @@ final class DateDiff<T> extends AbstractField<Integer> {
|
||||
case MILLISECOND:
|
||||
case MICROSECOND:
|
||||
case NANOSECOND:
|
||||
ctx.visit(partDiff(EPOCH).times(p == MILLISECOND ? inline(1_000) : p == MICROSECOND ? inline(1000000) : inline(1_000_000_000)));
|
||||
ctx.visit(partDiff(EPOCH).times(p == MILLISECOND ? inline(1000) : p == MICROSECOND ? inline(1000000) : inline(1000000000)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -241,10 +251,6 @@ final class DateDiff<T> extends AbstractField<Integer> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ctx.visit(castIfNeeded(date1.minus(date2), Integer.class));
|
||||
|
||||
@ -97,6 +97,7 @@ final class Names {
|
||||
static final Name N_DATEADD = unquotedName("dateadd");
|
||||
static final Name N_DATEDIFF = unquotedName("datediff");
|
||||
static final Name N_DATEPART = unquotedName("datepart");
|
||||
static final Name N_DAYS = unquotedName("days");
|
||||
static final Name N_DAYOFWEEK = unquotedName("dayofweek");
|
||||
static final Name N_DAYOFYEAR = unquotedName("dayofyear");
|
||||
static final Name N_DAYS_BETWEEN = unquotedName("days_between");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user