[#5643] Add DSL.currentLocalDate(), currentLocalTime(), currentLocalDateTime(), currentOffsetTime(), currentOffsetDateTime()
This commit is contained in:
parent
86c2a6ea3c
commit
c4e067f7d1
@ -42,27 +42,26 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class CurrentDate extends AbstractFunction<Date> {
|
||||
final class CurrentDate<T> extends AbstractFunction<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
CurrentDate() {
|
||||
super("current_date", SQLDataType.DATE);
|
||||
CurrentDate(DataType<T> type) {
|
||||
super("current_date", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
final Field<Date> getFunction0(Configuration configuration) {
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
|
||||
@ -92,9 +91,9 @@ final class CurrentDate extends AbstractFunction<Date> {
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
return DSL.field("{current_date}", SQLDataType.DATE);
|
||||
return DSL.field("{current_date}", getDataType());
|
||||
}
|
||||
|
||||
return function("current_date", SQLDataType.DATE);
|
||||
return function("current_date", getDataType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,27 +40,26 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import java.sql.Time;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class CurrentTime extends AbstractFunction<Time> {
|
||||
final class CurrentTime<T> extends AbstractFunction<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
CurrentTime() {
|
||||
super("current_time", SQLDataType.TIME);
|
||||
CurrentTime(DataType<T> type) {
|
||||
super("current_time", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
final Field<Time> getFunction0(Configuration configuration) {
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
|
||||
@ -82,7 +81,7 @@ final class CurrentTime extends AbstractFunction<Time> {
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
return DSL.field("{current_time}", SQLDataType.TIME);
|
||||
return DSL.field("{current_time}", getDataType());
|
||||
|
||||
|
||||
|
||||
@ -93,6 +92,6 @@ final class CurrentTime extends AbstractFunction<Time> {
|
||||
|
||||
}
|
||||
|
||||
return DSL.function("current_time", SQLDataType.TIME);
|
||||
return DSL.function("current_time", getDataType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,27 +42,26 @@ package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import org.jooq.Configuration;
|
||||
import org.jooq.DataType;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class CurrentTimestamp extends AbstractFunction<Timestamp> {
|
||||
final class CurrentTimestamp<T> extends AbstractFunction<T> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
CurrentTimestamp() {
|
||||
super("current_timestamp", SQLDataType.TIMESTAMP);
|
||||
CurrentTimestamp(DataType<T> type) {
|
||||
super("current_timestamp", type);
|
||||
}
|
||||
|
||||
@Override
|
||||
final Field<Timestamp> getFunction0(Configuration configuration) {
|
||||
final Field<T> getFunction0(Configuration configuration) {
|
||||
switch (configuration.family()) {
|
||||
|
||||
|
||||
@ -92,9 +91,9 @@ final class CurrentTimestamp extends AbstractFunction<Timestamp> {
|
||||
case HSQLDB:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
return DSL.field("{current_timestamp}", SQLDataType.TIMESTAMP);
|
||||
return DSL.field("{current_timestamp}", getDataType());
|
||||
}
|
||||
|
||||
return function("current_timestamp", SQLDataType.TIMESTAMP);
|
||||
return function("current_timestamp", getDataType());
|
||||
}
|
||||
}
|
||||
|
||||
@ -11499,7 +11499,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static Field<Date> currentDate() {
|
||||
return new CurrentDate();
|
||||
return new CurrentDate<Date>(SQLDataType.DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -11509,7 +11509,7 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static Field<Time> currentTime() {
|
||||
return new CurrentTime();
|
||||
return new CurrentTime<Time>(SQLDataType.TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -11519,9 +11519,61 @@ public class DSL {
|
||||
*/
|
||||
@Support
|
||||
public static Field<Timestamp> currentTimestamp() {
|
||||
return new CurrentTimestamp();
|
||||
return new CurrentTimestamp<Timestamp>(SQLDataType.TIMESTAMP);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current_date() function.
|
||||
* <p>
|
||||
* This translates into any dialect
|
||||
*/
|
||||
@Support
|
||||
public static Field<LocalDate> currentLocalDate() {
|
||||
return new CurrentDate<>(SQLDataType.LOCALDATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_time() function.
|
||||
* <p>
|
||||
* This translates into any dialect
|
||||
*/
|
||||
@Support
|
||||
public static Field<LocalTime> currentLocalTime() {
|
||||
return new CurrentTime<>(SQLDataType.LOCALTIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_timestamp() function.
|
||||
* <p>
|
||||
* This translates into any dialect
|
||||
*/
|
||||
@Support
|
||||
public static Field<LocalDateTime> currentLocalDateTime() {
|
||||
return new CurrentTimestamp<>(SQLDataType.LOCALDATETIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_time() function.
|
||||
* <p>
|
||||
* This translates into any dialect
|
||||
*/
|
||||
@Support
|
||||
public static Field<OffsetTime> currentOffsetTime() {
|
||||
return currentTime().cast(SQLDataType.OFFSETTIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current_timestamp() function.
|
||||
* <p>
|
||||
* This translates into any dialect
|
||||
*/
|
||||
@Support
|
||||
public static Field<OffsetDateTime> currentOffsetDateTime() {
|
||||
return currentTimestamp().cast(SQLDataType.OFFSETDATETIME);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the date difference in number of days.
|
||||
* <p>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user