[jOOQ/jOOQ#8737] Fix date arithmetic does not support fractional seconds
Date arithmetic now uses strftime(), so that fractional seconds don't get trimmed.
This commit is contained in:
parent
37727bee41
commit
56ee881246
@ -176,7 +176,7 @@ final class DateAdd<T> extends AbstractFunction<T> {
|
||||
default: throwUnsupported();
|
||||
}
|
||||
|
||||
return DSL.field("{datetime}({0}, '+' || {1} || {2})", getDataType(), date, interval, inline(keyword));
|
||||
return DSL.field("{strftime}('%Y-%m-%d %H:%M:%f', {0}, {1})", getDataType(), date, interval.concat(inline(keyword)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -376,7 +376,7 @@ final class Expression<T> extends AbstractFunction<T> {
|
||||
interval = interval.neg();
|
||||
|
||||
interval = interval.concat(inline(ytm ? " months" : " seconds"));
|
||||
return DSL.field("{datetime}({0}, {1})", getDataType(), lhs, interval);
|
||||
return DSL.field("{strftime}('%Y-%m-%d %H:%M:%f', {0}, {1})", getDataType(), lhs, interval);
|
||||
}
|
||||
|
||||
|
||||
@ -651,9 +651,9 @@ final class Expression<T> extends AbstractFunction<T> {
|
||||
|
||||
case SQLITE:
|
||||
if (operator == ADD)
|
||||
return DSL.field("{datetime}({0}, {1})", getDataType(), lhs, rhsAsNumber().concat(inline(" day")));
|
||||
return DSL.field("{strftime}('%Y-%m-%d %H:%M:%f', {0}, {1})", getDataType(), lhs, rhsAsNumber().concat(inline(" day")));
|
||||
else
|
||||
return DSL.field("{datetime}({0}, {1})", getDataType(), lhs, rhsAsNumber().neg().concat(inline(" day")));
|
||||
return DSL.field("{strftime}('%Y-%m-%d %H:%M:%f', {0}, {1})", getDataType(), lhs, rhsAsNumber().neg().concat(inline(" day")));
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user