Skip to content

Commit

Permalink
[#7171] DATE, TIME, TIMESTAMP, INTERVAL column references (not literals)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed May 2, 2018
1 parent 3bb2b1c commit 883029a
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions jOOQ/src/main/java/org/jooq/impl/ParserImpl.java
Expand Up @@ -5027,6 +5027,8 @@ private static final Field<?> parseFieldGroupingIdIf(ParserContext ctx) {
}

private static final Field<?> parseFieldTimestampLiteralIf(ParserContext ctx) {
int position = ctx.position();

if (parseKeywordIf(ctx, "TIMESTAMP")) {
if (parseKeywordIf(ctx, "WITHOUT TIME ZONE")) {
return inline(parseTimestampLiteral(ctx));
Expand All @@ -5036,9 +5038,13 @@ else if (parseIf(ctx, '(')) {
parse(ctx, ')');
return timestamp((Field) f);
}
else {
else if (peek(ctx, '\'')) {
return inline(parseTimestampLiteral(ctx));
}
else {
ctx.position(position);
return field(parseIdentifier(ctx));
}
}

return null;
Expand All @@ -5054,6 +5060,8 @@ private static final Timestamp parseTimestampLiteral(ParserContext ctx) {
}

private static final Field<?> parseFieldTimeLiteralIf(ParserContext ctx) {
int position = ctx.position();

if (parseKeywordIf(ctx, "TIME")) {
if (parseKeywordIf(ctx, "WITHOUT TIME ZONE")) {
return inline(parseTimeLiteral(ctx));
Expand All @@ -5063,9 +5071,13 @@ else if (parseIf(ctx, '(')) {
parse(ctx, ')');
return time((Field) f);
}
else {
else if (peek(ctx, '\'')) {
return inline(parseTimeLiteral(ctx));
}
else {
ctx.position(position);
return field(parseIdentifier(ctx));
}
}

return null;
Expand All @@ -5081,8 +5093,17 @@ private static final Time parseTimeLiteral(ParserContext ctx) {
}

private static final Field<?> parseFieldIntervalLiteralIf(ParserContext ctx) {
if (parseKeywordIf(ctx, "INTERVAL"))
return inline(parseIntervalLiteral(ctx));
int position = ctx.position();

if (parseKeywordIf(ctx, "INTERVAL")) {
if (peek(ctx, '\'')) {
return inline(parseIntervalLiteral(ctx));
}
else {
ctx.position(position);
return field(parseIdentifier(ctx));
}
}

return null;
}
Expand All @@ -5103,15 +5124,21 @@ private static final Interval parseIntervalLiteral(ParserContext ctx) {
}

private static final Field<?> parseFieldDateLiteralIf(ParserContext ctx) {
int position = ctx.position();

if (parseKeywordIf(ctx, "DATE")) {
if (parseIf(ctx, '(')) {
Field<?> f = parseField(ctx, S);
parse(ctx, ')');
return date((Field) f);
}
else {
else if (peek(ctx, '\'')) {
return inline(parseDateLiteral(ctx));
}
else {
ctx.position(position);
return field(parseIdentifier(ctx));
}
}

return null;
Expand Down

0 comments on commit 883029a

Please sign in to comment.