[#2500] Error when selecting from YEAR(4) data type in MySQL - Added
failing integration test
This commit is contained in:
parent
f1fdfe18ba
commit
2e6c1362c6
@ -98,6 +98,7 @@ import org.jooq.test.mysql.generatedclasses.tables.TBook;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TBookStore;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TBookToBookStore;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TBooleans;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TDates;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TExoticTypes;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TIdentityPk;
|
||||
import org.jooq.test.mysql.generatedclasses.tables.TTriggers;
|
||||
@ -850,4 +851,33 @@ public class MySQLTest extends jOOQAbstractTest<
|
||||
assertEquals(TBookStatus.ON_STOCK, MySQLDSL.enumType(TBookStatus.class, 3));
|
||||
assertNull(MySQLDSL.enumType(TBookStatus.class, 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMySQLYearType() throws Exception {
|
||||
jOOQAbstractTest.reset = false;
|
||||
|
||||
Date d1 = Date.valueOf("2012-01-01");
|
||||
Date d2 = Date.valueOf("1999-01-01");
|
||||
|
||||
assertEquals(2,
|
||||
create().insertInto(T_DATES,
|
||||
TDates.ID,
|
||||
TDates.Y2,
|
||||
TDates.Y4)
|
||||
.values(1, d1, d1)
|
||||
.values(2, d2, d2)
|
||||
.execute());
|
||||
|
||||
Result<?> dates =
|
||||
create().select(TDates.Y2, TDates.Y4)
|
||||
.from(T_DATES)
|
||||
.orderBy(TDates.ID)
|
||||
.fetch();
|
||||
|
||||
assertEquals(2, dates.size());
|
||||
assertEquals(d1, dates.getValue(0, 0));
|
||||
assertEquals(d1, dates.getValue(0, 1));
|
||||
assertEquals(d2, dates.getValue(1, 0));
|
||||
assertEquals(d2, dates.getValue(1, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,6 +58,8 @@ CREATE TABLE t_dates (
|
||||
ts datetime,
|
||||
d_int int,
|
||||
ts_bigint bigint,
|
||||
y2 year(2),
|
||||
y4 year(4),
|
||||
|
||||
CONSTRAINT pk_t_dates PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.mysql.generatedclasses.tables;
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class TDates extends org.jooq.impl.TableImpl<org.jooq.test.mysql.generatedclasses.tables.records.TDatesRecord> {
|
||||
|
||||
private static final long serialVersionUID = 1552584156;
|
||||
private static final long serialVersionUID = -2028153294;
|
||||
|
||||
/**
|
||||
* The singleton instance of <code>test.t_dates</code>
|
||||
@ -54,6 +54,16 @@ public class TDates extends org.jooq.impl.TableImpl<org.jooq.test.mysql.generate
|
||||
*/
|
||||
public static final org.jooq.TableField<org.jooq.test.mysql.generatedclasses.tables.records.TDatesRecord, java.lang.Long> TS_BIGINT = createField("ts_bigint", org.jooq.impl.SQLDataType.BIGINT, T_DATES);
|
||||
|
||||
/**
|
||||
* The column <code>test.t_dates.y2</code>.
|
||||
*/
|
||||
public static final org.jooq.TableField<org.jooq.test.mysql.generatedclasses.tables.records.TDatesRecord, java.sql.Date> Y2 = createField("y2", org.jooq.impl.SQLDataType.DATE, T_DATES);
|
||||
|
||||
/**
|
||||
* The column <code>test.t_dates.y4</code>.
|
||||
*/
|
||||
public static final org.jooq.TableField<org.jooq.test.mysql.generatedclasses.tables.records.TDatesRecord, java.sql.Date> Y4 = createField("y4", org.jooq.impl.SQLDataType.DATE, T_DATES);
|
||||
|
||||
/**
|
||||
* No further instances allowed
|
||||
*/
|
||||
|
||||
@ -79,4 +79,18 @@ public class TDatesDao extends org.jooq.impl.DAOImpl<org.jooq.test.mysql.generat
|
||||
public java.util.List<org.jooq.test.mysql.generatedclasses.tables.pojos.TDates> fetchByTsBigint(java.lang.Long... values) {
|
||||
return fetch(org.jooq.test.mysql.generatedclasses.tables.TDates.TS_BIGINT, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch records that have <code>y2 IN (values)</code>
|
||||
*/
|
||||
public java.util.List<org.jooq.test.mysql.generatedclasses.tables.pojos.TDates> fetchByY2(java.sql.Date... values) {
|
||||
return fetch(org.jooq.test.mysql.generatedclasses.tables.TDates.Y2, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch records that have <code>y4 IN (values)</code>
|
||||
*/
|
||||
public java.util.List<org.jooq.test.mysql.generatedclasses.tables.pojos.TDates> fetchByY4(java.sql.Date... values) {
|
||||
return fetch(org.jooq.test.mysql.generatedclasses.tables.TDates.Y4, values);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ package org.jooq.test.mysql.generatedclasses.tables.pojos;
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class TDates implements java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1631068874;
|
||||
private static final long serialVersionUID = 1324210540;
|
||||
|
||||
private final java.lang.Integer id;
|
||||
private final java.sql.Date d;
|
||||
@ -17,6 +17,8 @@ public class TDates implements java.io.Serializable {
|
||||
private final java.sql.Timestamp ts;
|
||||
private final java.lang.Integer dInt;
|
||||
private final java.lang.Long tsBigint;
|
||||
private final java.sql.Date y2;
|
||||
private final java.sql.Date y4;
|
||||
|
||||
public TDates(
|
||||
java.lang.Integer id,
|
||||
@ -24,7 +26,9 @@ public class TDates implements java.io.Serializable {
|
||||
java.sql.Time t,
|
||||
java.sql.Timestamp ts,
|
||||
java.lang.Integer dInt,
|
||||
java.lang.Long tsBigint
|
||||
java.lang.Long tsBigint,
|
||||
java.sql.Date y2,
|
||||
java.sql.Date y4
|
||||
) {
|
||||
this.id = id;
|
||||
this.d = d;
|
||||
@ -32,6 +36,8 @@ public class TDates implements java.io.Serializable {
|
||||
this.ts = ts;
|
||||
this.dInt = dInt;
|
||||
this.tsBigint = tsBigint;
|
||||
this.y2 = y2;
|
||||
this.y4 = y4;
|
||||
}
|
||||
|
||||
public java.lang.Integer getId() {
|
||||
@ -57,4 +63,12 @@ public class TDates implements java.io.Serializable {
|
||||
public java.lang.Long getTsBigint() {
|
||||
return this.tsBigint;
|
||||
}
|
||||
|
||||
public java.sql.Date getY2() {
|
||||
return this.y2;
|
||||
}
|
||||
|
||||
public java.sql.Date getY4() {
|
||||
return this.y4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,9 +7,9 @@ package org.jooq.test.mysql.generatedclasses.tables.records;
|
||||
* This class is generated by jOOQ.
|
||||
*/
|
||||
@java.lang.SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.mysql.generatedclasses.tables.records.TDatesRecord> implements org.jooq.Record6<java.lang.Integer, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.lang.Integer, java.lang.Long> {
|
||||
public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.test.mysql.generatedclasses.tables.records.TDatesRecord> implements org.jooq.Record8<java.lang.Integer, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.lang.Integer, java.lang.Long, java.sql.Date, java.sql.Date> {
|
||||
|
||||
private static final long serialVersionUID = 2068625224;
|
||||
private static final long serialVersionUID = 1193743222;
|
||||
|
||||
/**
|
||||
* Setter for <code>test.t_dates.id</code>.
|
||||
@ -95,6 +95,34 @@ public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.tes
|
||||
return (java.lang.Long) getValue(5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>test.t_dates.y2</code>.
|
||||
*/
|
||||
public void setY2(java.sql.Date value) {
|
||||
setValue(6, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>test.t_dates.y2</code>.
|
||||
*/
|
||||
public java.sql.Date getY2() {
|
||||
return (java.sql.Date) getValue(6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>test.t_dates.y4</code>.
|
||||
*/
|
||||
public void setY4(java.sql.Date value) {
|
||||
setValue(7, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>test.t_dates.y4</code>.
|
||||
*/
|
||||
public java.sql.Date getY4() {
|
||||
return (java.sql.Date) getValue(7);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Primary key information
|
||||
// -------------------------------------------------------------------------
|
||||
@ -108,23 +136,23 @@ public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.tes
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Record6 type implementation
|
||||
// Record8 type implementation
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Row6<java.lang.Integer, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.lang.Integer, java.lang.Long> fieldsRow() {
|
||||
return (org.jooq.Row6) super.fieldsRow();
|
||||
public org.jooq.Row8<java.lang.Integer, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.lang.Integer, java.lang.Long, java.sql.Date, java.sql.Date> fieldsRow() {
|
||||
return (org.jooq.Row8) super.fieldsRow();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Row6<java.lang.Integer, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.lang.Integer, java.lang.Long> valuesRow() {
|
||||
return (org.jooq.Row6) super.valuesRow();
|
||||
public org.jooq.Row8<java.lang.Integer, java.sql.Date, java.sql.Time, java.sql.Timestamp, java.lang.Integer, java.lang.Long, java.sql.Date, java.sql.Date> valuesRow() {
|
||||
return (org.jooq.Row8) super.valuesRow();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,6 +203,22 @@ public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.tes
|
||||
return org.jooq.test.mysql.generatedclasses.tables.TDates.TS_BIGINT;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.sql.Date> field7() {
|
||||
return org.jooq.test.mysql.generatedclasses.tables.TDates.Y2;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public org.jooq.Field<java.sql.Date> field8() {
|
||||
return org.jooq.test.mysql.generatedclasses.tables.TDates.Y4;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@ -223,6 +267,22 @@ public class TDatesRecord extends org.jooq.impl.UpdatableRecordImpl<org.jooq.tes
|
||||
return getTsBigint();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.sql.Date value7() {
|
||||
return getY2();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public java.sql.Date value8() {
|
||||
return getY4();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Constructors
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user