[#2753] DATE_DIFF() with CURRENT_DATE() returns wrong precision in Oracle

This commit is contained in:
Lukas Eder 2013-09-18 13:39:52 +02:00
parent 15d01bc6f1
commit 6b60fc1dd3
3 changed files with 26 additions and 8 deletions

View File

@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SYBASE;
import static org.jooq.conf.StatementType.STATIC_STATEMENT;
import static org.jooq.impl.DSL.cast;
import static org.jooq.impl.DSL.castNull;
import static org.jooq.impl.DSL.currentDate;
import static org.jooq.impl.DSL.dateAdd;
import static org.jooq.impl.DSL.dateDiff;
import static org.jooq.impl.DSL.field;
@ -1582,12 +1583,24 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
assertEquals(new DayToSecond(1, 6).neg(), record.getValue("ts1"));
assertEquals(new DayToSecond(1, 6), record.getValue("ts2"));
}
private Calendar cal() {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(-3600000);
return cal;
}
@Test
public void testCurrentDate() throws Exception {
Field<Timestamp> ts = currentDate().cast(Timestamp.class).as("ts");
Field<Date> d = currentDate().as("d");
Record2<Date, Timestamp> record =
create().select(d, ts)
.fetchOne();
assertEquals(record.value1().getTime(), record.value2().getTime());
}
@Test
public void testUUIDDataType() throws Exception {

View File

@ -1650,11 +1650,16 @@ public abstract class jOOQAbstractTest<
public void testDateTime() throws Exception {
new DataTypeTests(this).testDateTime();
}
@Test
public void testDateTimeArithmetic() throws Exception {
new DataTypeTests(this).testDateTimeArithmetic();
}
@Test
public void testDateTimeArithmetic() throws Exception {
new DataTypeTests(this).testDateTimeArithmetic();
}
@Test
public void testCurrentDate() throws Exception {
new DataTypeTests(this).testCurrentDate();
}
@Test
public void testManager() throws Exception {

View File

@ -66,8 +66,8 @@ class CurrentDate extends AbstractFunction<Date> {
final Field<Date> getFunction0(Configuration configuration) {
switch (configuration.dialect().family()) {
/* [pro] */
case ORACLE:
return field("sysdate", SQLDataType.DATE);
case ORACLE:
return field("{trunc}({sysdate})", SQLDataType.DATE);
case DB2:
case INGRES: