- [#7237] now() function
- [#7171] current_timestamp(), current_time(), and current_date() can be functions, not just literals
This commit is contained in:
lukaseder 2018-03-01 11:32:35 +01:00
parent 052872de87
commit 7018e7a9ee
2 changed files with 17 additions and 4 deletions

View File

@ -13550,6 +13550,14 @@ public class DSL {
return new CurrentTimestamp<Timestamp>(SQLDataType.TIMESTAMP);
}
/**
* Synonym for {@link #currentTimestamp()}.
*/
@Support
public static Field<Timestamp> now() {
return currentTimestamp();
}
/**
* Get the current_date() function returning a SQL standard

View File

@ -125,6 +125,7 @@ import static org.jooq.impl.DSL.minDistinct;
import static org.jooq.impl.DSL.minute;
import static org.jooq.impl.DSL.mode;
import static org.jooq.impl.DSL.month;
import static org.jooq.impl.DSL.now;
import static org.jooq.impl.DSL.nthValue;
import static org.jooq.impl.DSL.ntile;
import static org.jooq.impl.DSL.nullif;
@ -3706,11 +3707,11 @@ final class ParserImpl implements Parser {
return field;
if (D.is(type))
if (parseKeywordIf(ctx, "CURRENT_TIMESTAMP"))
if (parseKeywordIf(ctx, "CURRENT_TIMESTAMP") && (parseIf(ctx, '(') && parse(ctx, ')') || true))
return currentTimestamp();
else if (parseKeywordIf(ctx, "CURRENT_TIME"))
else if (parseKeywordIf(ctx, "CURRENT_TIME") && (parseIf(ctx, '(') && parse(ctx, ')') || true))
return currentTime();
else if (parseKeywordIf(ctx, "CURRENT_DATE"))
else if (parseKeywordIf(ctx, "CURRENT_DATE") && (parseIf(ctx, '(') && parse(ctx, ')') || true))
return currentDate();
if ((field = parseFieldCaseIf(ctx)) != null)
@ -3869,6 +3870,8 @@ final class ParserImpl implements Parser {
return field;
else if ((field = parseNextvalCurrvalIf(ctx, SequenceMethod.NEXTVAL)) != null)
return field;
else if (parseFunctionNameIf(ctx, "NOW") && parse(ctx, '(') && parse(ctx, ')'))
return now();
break;
@ -6917,9 +6920,11 @@ final class ParserImpl implements Parser {
return true;
}
private static final void parse(ParserContext ctx, char c) {
private static final boolean parse(ParserContext ctx, char c) {
if (!parseIf(ctx, c))
throw ctx.unexpectedToken();
return true;
}
private static final boolean parseIf(ParserContext ctx, char c) {