[jOOQ/jOOQ#10452] [jOOQ/jOOQ#10572] Parse and ignore interval precision
This commit is contained in:
parent
91d4ca06c6
commit
09919669c2
@ -90,6 +90,7 @@ import static org.jooq.impl.Keywords.K_INTERVAL;
|
||||
import static org.jooq.impl.Keywords.K_MILLISECOND;
|
||||
import static org.jooq.impl.Keywords.K_MONTH;
|
||||
import static org.jooq.impl.Keywords.K_SECOND;
|
||||
import static org.jooq.impl.Keywords.K_TO;
|
||||
import static org.jooq.impl.Keywords.K_YEAR_MONTH;
|
||||
import static org.jooq.impl.Keywords.K_YEAR_TO_MONTH;
|
||||
import static org.jooq.impl.Names.N_ADD_DAYS;
|
||||
@ -624,6 +625,24 @@ final class Expression<T> extends AbstractTransformable<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -9027,6 +9027,19 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
return null;
|
||||
}
|
||||
|
||||
private final boolean parseIntervalPrecisionKeywordIf(String keyword) {
|
||||
if (parseKeywordIf(keyword)) {
|
||||
if (parseIf('(')) {
|
||||
parseUnsignedIntegerLiteral();
|
||||
parse(')');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private final Interval parseIntervalLiteral() {
|
||||
Interval result = parsePostgresIntervalLiteralIf();
|
||||
if (result != null)
|
||||
@ -9035,41 +9048,41 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
|
||||
String string = parseStringLiteral();
|
||||
String message = "Illegal interval literal";
|
||||
|
||||
if (parseKeywordIf("YEAR"))
|
||||
if (parseKeywordIf("TO") && parseKeyword("MONTH"))
|
||||
if (parseIntervalPrecisionKeywordIf("YEAR"))
|
||||
if (parseKeywordIf("TO") && parseIntervalPrecisionKeywordIf("MONTH"))
|
||||
return requireNotNull(YearToMonth.yearToMonth(string), message);
|
||||
else
|
||||
return requireNotNull(YearToMonth.year(string), message);
|
||||
else if (parseKeywordIf("MONTH"))
|
||||
else if (parseIntervalPrecisionKeywordIf("MONTH"))
|
||||
return requireNotNull(YearToMonth.month(string), message);
|
||||
else if (parseKeywordIf("DAY"))
|
||||
else if (parseIntervalPrecisionKeywordIf("DAY"))
|
||||
if (parseKeywordIf("TO"))
|
||||
if (parseKeywordIf("SECOND"))
|
||||
if (parseIntervalPrecisionKeywordIf("SECOND"))
|
||||
return requireNotNull(DayToSecond.dayToSecond(string), message);
|
||||
else if (parseKeywordIf("MINUTE"))
|
||||
else if (parseIntervalPrecisionKeywordIf("MINUTE"))
|
||||
return requireNotNull(DayToSecond.dayToMinute(string), message);
|
||||
else if (parseKeywordIf("HOUR"))
|
||||
else if (parseIntervalPrecisionKeywordIf("HOUR"))
|
||||
return requireNotNull(DayToSecond.dayToHour(string), message);
|
||||
else
|
||||
throw expected("HOUR", "MINUTE", "SECOND");
|
||||
else
|
||||
return requireNotNull(DayToSecond.day(string), message);
|
||||
else if (parseKeywordIf("HOUR"))
|
||||
else if (parseIntervalPrecisionKeywordIf("HOUR"))
|
||||
if (parseKeywordIf("TO"))
|
||||
if (parseKeywordIf("SECOND"))
|
||||
if (parseIntervalPrecisionKeywordIf("SECOND"))
|
||||
return requireNotNull(DayToSecond.hourToSecond(string), message);
|
||||
else if (parseKeywordIf("MINUTE"))
|
||||
else if (parseIntervalPrecisionKeywordIf("MINUTE"))
|
||||
return requireNotNull(DayToSecond.hourToMinute(string), message);
|
||||
else
|
||||
throw expected("MINUTE", "SECOND");
|
||||
else
|
||||
return requireNotNull(DayToSecond.hour(string), message);
|
||||
else if (parseKeywordIf("MINUTE"))
|
||||
if (parseKeywordIf("TO") && parseKeyword("SECOND"))
|
||||
else if (parseIntervalPrecisionKeywordIf("MINUTE"))
|
||||
if (parseKeywordIf("TO") && parseIntervalPrecisionKeywordIf("SECOND"))
|
||||
return requireNotNull(DayToSecond.minuteToSecond(string), message);
|
||||
else
|
||||
return requireNotNull(DayToSecond.minute(string), message);
|
||||
else if (parseKeywordIf("SECOND"))
|
||||
else if (parseIntervalPrecisionKeywordIf("SECOND"))
|
||||
return requireNotNull(DayToSecond.second(string), message);
|
||||
|
||||
DayToSecond ds = DayToSecond.valueOf(string);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user