[#1147] Add integration tests for executing SQL generated using Factory.renderInlined()

This commit is contained in:
Lukas Eder 2012-02-17 15:29:54 +00:00
parent 0ff986314f
commit 83e97c2870
7 changed files with 79 additions and 33 deletions

View File

@ -40,6 +40,8 @@ import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Connection;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -241,6 +243,30 @@ public abstract class BaseTest<
return delegate.TUnsigned_U_LONG();
}
public Table<DATE> TDates() {
return delegate.TDates();
}
@SuppressWarnings("unchecked")
protected final TableField<DATE, Integer> TDates_ID() {
return (TableField<DATE, Integer>) getField(TDates(), "ID");
}
@SuppressWarnings("unchecked")
protected final TableField<DATE, Date> TDates_D() {
return (TableField<DATE, Date>) getField(TDates(), "D");
}
@SuppressWarnings("unchecked")
protected final TableField<DATE, Time> TDates_T() {
return (TableField<DATE, Time>) getField(TDates(), "T");
}
@SuppressWarnings("unchecked")
protected final TableField<DATE, Timestamp> TDates_TS() {
return (TableField<DATE, Timestamp>) getField(TDates(), "TS");
}
protected Table<X> TArrays() {
return delegate.TArrays();
}

View File

@ -489,7 +489,7 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, D, T, U, I, IPK, T658, T725, T639
assertEquals(sequence, schema.getSequence(sequence.getName()));
}
int tables = 16;
int tables = 17;
// The additional T_DIRECTORY table for recursive queries
if (supportsRecursiveQueries()) {

View File

@ -276,6 +276,9 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, D, T, U, I, IPK, T658, T725, T639
boolean derby = (getDialect() == DERBY);
// [#1147] Some data types need special care when inlined
// Selection from DUAL
// -------------------
String s1 = "test";
String s2 = "no SQL 'injection here; <<`'";
String s3 = "''";
@ -334,4 +337,38 @@ extends BaseTest<A, B, S, B2S, BS, L, X, DATE, D, T, U, I, IPK, T658, T725, T639
assertEquals(asList(new String(by1), (derby ? new String(by2) : by2), bool1, bool2, bool3), asList(array4));
}
@Test
public void testInlinedBindValuesForDatetime() throws Exception {
jOOQAbstractTest.reset = false;
Date d1 = Date.valueOf("1981-07-10");
Time t1 = Time.valueOf("12:01:15");
Timestamp ts1 = Timestamp.valueOf("1981-07-10 12:01:15");
Factory create = create(new Settings()
.withExecution(new Execution()
.withStatementType(StatementType.STATEMENT)));
DATE date = create.newRecord(TDates());
date.setValue(TDates_ID(), 1);
assertEquals(1, date.store());
date.setValue(TDates_ID(), 2);
date.setValue(TDates_D(), d1);
date.setValue(TDates_T(), t1);
date.setValue(TDates_TS(), ts1);
assertEquals(1, date.store());
Result<Record> dates =
create.select(TDates_ID(), TDates_D(), TDates_T(), TDates_TS())
.from(TDates())
.orderBy(TDates_ID())
.fetch();
assertEquals(2, dates.size());
assertEquals(asList(1, 2), dates.getValues(TDates_ID()));
assertEquals(asList(1, null, null, null), asList(dates.get(0).intoArray()));
assertEquals(asList((Object) 2, d1, t1, ts1), asList(dates.get(1).intoArray()));
}
}

View File

@ -58,11 +58,11 @@ CREATE TABLE t_identity (
CREATE TABLE t_dates (
id int,
d date,
t time,
ts timestamp,
d_int int,
ts_bigint bigint,
d date null,
t time null,
ts datetime null,
d_int int null,
ts_bigint bigint null,
CONSTRAINT pk_t_dates PRIMARY KEY (id)
)

View File

@ -8,7 +8,7 @@ package org.jooq.test.ase.generatedclasses.tables;
*/
public class TDates extends org.jooq.impl.UpdatableTableImpl<org.jooq.test.ase.generatedclasses.tables.records.TDatesRecord> {
private static final long serialVersionUID = -1986889297;
private static final long serialVersionUID = -1429057447;
/**
* The singleton instance of t_dates
@ -47,11 +47,8 @@ public class TDates extends org.jooq.impl.UpdatableTableImpl<org.jooq.test.ase.g
/**
* An uncommented item
*
* The SQL type of this item (timestamp) could not be mapped.<br/>
* Deserialising this field might not work!
*/
public static final org.jooq.TableField<org.jooq.test.ase.generatedclasses.tables.records.TDatesRecord, java.lang.Object> TS = createField("ts", org.jooq.util.ase.ASEDataType.getDefaultDataType("timestamp"), T_DATES);
public static final org.jooq.TableField<org.jooq.test.ase.generatedclasses.tables.records.TDatesRecord, java.sql.Timestamp> TS = createField("ts", org.jooq.impl.SQLDataType.TIMESTAMP, T_DATES);
/**
* An uncommented item

View File

@ -8,7 +8,7 @@ package org.jooq.test.ase.generatedclasses.tables.records;
*/
public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.ase.generatedclasses.tables.records.TDatesRecord> {
private static final long serialVersionUID = 560535563;
private static final long serialVersionUID = 690713213;
/**
* An uncommented item
@ -58,21 +58,15 @@ public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.tes
/**
* An uncommented item
*
* The SQL type of this item (timestamp) could not be mapped.<br/>
* Deserialising this field might not work!
*/
public void setTs(java.lang.Object value) {
public void setTs(java.sql.Timestamp value) {
setValue(org.jooq.test.ase.generatedclasses.tables.TDates.TS, value);
}
/**
* An uncommented item
*
* The SQL type of this item (timestamp) could not be mapped.<br/>
* Deserialising this field might not work!
*/
public java.lang.Object getTs() {
public java.sql.Timestamp getTs() {
return getValue(org.jooq.test.ase.generatedclasses.tables.TDates.TS);
}

View File

@ -496,19 +496,6 @@ public abstract class jOOQAbstractTest<
protected abstract TableField<U, ULong> TUnsigned_U_LONG();
protected abstract Table<DATE> TDates();
protected final TableField<DATE, Integer> TDates_ID() {
return (TableField<DATE, Integer>) TDates().getField("ID");
}
protected final TableField<DATE, Date> TDates_D() {
return (TableField<DATE, Date>) TDates().getField("D");
}
protected final TableField<DATE, Time> TDates_T() {
return (TableField<DATE, Time>) TDates().getField("T");
}
protected final TableField<DATE, Timestamp> TDates_TS() {
return (TableField<DATE, Timestamp>) TDates().getField("TS");
}
protected abstract Table<X> TArrays();
protected abstract TableField<X, Integer> TArrays_ID();
@ -1318,6 +1305,11 @@ public abstract class jOOQAbstractTest<
new RenderAndBindTests(this).testInlinedBindValues();
}
@Test
public void testInlinedBindValuesForDatetime() throws Exception {
new RenderAndBindTests(this).testInlinedBindValuesForDatetime();
}
@Test
public void testPivotClause() throws Exception {
new ExoticTests(this).testPivotClause();