[#3571] Converted Data Type does not propagate nullable and defaulted properties
This commit is contained in:
parent
008c1e6cd8
commit
f4cee633c0
@ -1193,7 +1193,14 @@
|
||||
<!-- [#2844] This typo should emit a warning -->
|
||||
<customtype>
|
||||
</customtype>
|
||||
|
||||
|
||||
<!-- [#3571] Rewrite types to check if nullable() and defaulted() flags are propagated -->
|
||||
<customType>
|
||||
<name>3571</name>
|
||||
<type>org.jooq.test.all.converters.T_3571</type>
|
||||
<converter>org.jooq.test.all.converters.T_3571_Converter</converter>
|
||||
</customType>
|
||||
|
||||
<customType>
|
||||
<name>org.jooq.test.all.converters.Boolean_10</name>
|
||||
<converter>org.jooq.test.all.converters.Boolean_10_Converter</converter>
|
||||
@ -1226,6 +1233,12 @@
|
||||
|
||||
<forcedTypes>
|
||||
|
||||
<!-- [#3571] Rewrite types to check if nullable() and defaulted() flags are propagated -->
|
||||
<forcedType>
|
||||
<name>3571</name>
|
||||
<expression>(?i:.*?\.t_3571\..*)</expression>
|
||||
</forcedType>
|
||||
|
||||
<!-- [#2486] Remove precision and scale from existing DECIMALs -->
|
||||
<forcedType>
|
||||
<name>DECIMAL</name>
|
||||
|
||||
@ -53,12 +53,21 @@ DROP TABLE IF EXISTS t_3488_abc_xyz_eee/
|
||||
DROP TABLE IF EXISTS t_3488_abcxyz_eee/
|
||||
DROP TABLE IF EXISTS t_3488_abc_xyzeee/
|
||||
DROP TABLE IF EXISTS t_3488_abcxyzeee/
|
||||
DROP TABLE IF EXISTS t_3571/
|
||||
DROP TABLE IF EXISTS t_unsigned/
|
||||
DROP TABLE IF EXISTS t_booleans/
|
||||
DROP TABLE IF EXISTS t_identity/
|
||||
DROP TABLE IF EXISTS t_identity_pk/
|
||||
DROP TABLE IF EXISTS t_2327_uk_only/
|
||||
|
||||
CREATE TABLE t_3571 (
|
||||
e1 INTEGER,
|
||||
e2 INTEGER NOT NULL,
|
||||
e3 INTEGER DEFAULT 1,
|
||||
e4 INTEGER NOT NULL DEFAULT 1
|
||||
)
|
||||
/
|
||||
|
||||
CREATE TABLE t_2327_uk_only (
|
||||
id INTEGER,
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ import static org.jooq.impl.DSL.select;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.T_2486;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.T_2698;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.T_3571;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.T_639_NUMBERS_TABLE;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.T_725_LOB_TEST;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.T_785;
|
||||
@ -69,7 +70,9 @@ import static org.jooq.test.h2.generatedclasses.Tables.V_BOOK;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.V_LIBRARY;
|
||||
import static org.jooq.test.h2.generatedclasses.Tables.X_UNUSED;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@ -1060,4 +1063,16 @@ public class H2Test extends jOOQAbstractTest<
|
||||
assertEquals(0, T_2486.VAL8.getDataType().scale());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testH2MetaData3571() {
|
||||
assertTrue(T_3571.E1.getDataType().nullable());
|
||||
assertFalse(T_3571.E1.getDataType().defaulted());
|
||||
assertFalse(T_3571.E2.getDataType().nullable());
|
||||
assertFalse(T_3571.E2.getDataType().defaulted());
|
||||
assertTrue(T_3571.E3.getDataType().nullable());
|
||||
assertTrue(T_3571.E3.getDataType().defaulted());
|
||||
assertFalse(T_3571.E4.getDataType().nullable());
|
||||
assertTrue(T_3571.E4.getDataType().defaulted());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This work is dual-licensed
|
||||
* - under the Apache Software License 2.0 (the "ASL")
|
||||
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
|
||||
* =============================================================================
|
||||
* You may choose which license applies to you:
|
||||
*
|
||||
* - If you're using this work with Open Source databases, you may choose
|
||||
* either ASL or jOOQ License.
|
||||
* - If you're using this work with at least one commercial database, you must
|
||||
* choose jOOQ License
|
||||
*
|
||||
* For more information, please visit http://www.jooq.org/licenses
|
||||
*
|
||||
* Apache Software License 2.0:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* jOOQ License and Maintenance Agreement:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Data Geekery grants the Customer the non-exclusive, timely limited and
|
||||
* non-transferable license to install and use the Software under the terms of
|
||||
* the jOOQ License and Maintenance Agreement.
|
||||
*
|
||||
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
|
||||
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
|
||||
*/
|
||||
package org.jooq.test.all.converters;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public enum T_3571 {
|
||||
|
||||
A, B, C
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) 2009-2014, Data Geekery GmbH (http://www.datageekery.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This work is dual-licensed
|
||||
* - under the Apache Software License 2.0 (the "ASL")
|
||||
* - under the jOOQ License and Maintenance Agreement (the "jOOQ License")
|
||||
* =============================================================================
|
||||
* You may choose which license applies to you:
|
||||
*
|
||||
* - If you're using this work with Open Source databases, you may choose
|
||||
* either ASL or jOOQ License.
|
||||
* - If you're using this work with at least one commercial database, you must
|
||||
* choose jOOQ License
|
||||
*
|
||||
* For more information, please visit http://www.jooq.org/licenses
|
||||
*
|
||||
* Apache Software License 2.0:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* jOOQ License and Maintenance Agreement:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Data Geekery grants the Customer the non-exclusive, timely limited and
|
||||
* non-transferable license to install and use the Software under the terms of
|
||||
* the jOOQ License and Maintenance Agreement.
|
||||
*
|
||||
* This library is distributed with a LIMITED WARRANTY. See the jOOQ License
|
||||
* and Maintenance Agreement for more details: http://www.jooq.org/licensing
|
||||
*/
|
||||
package org.jooq.test.all.converters;
|
||||
|
||||
import org.jooq.impl.EnumConverter;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
public class T_3571_Converter extends EnumConverter<Integer, T_3571> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = 4877220039498982300L;
|
||||
|
||||
public T_3571_Converter() {
|
||||
super(Integer.class, T_3571.class);
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,17 @@ class ConvertedDataType<T, U> extends DefaultDataType<U> {
|
||||
private final Converter<? super T, U> converter;
|
||||
|
||||
ConvertedDataType(DataType<T> delegate, Converter<? super T, U> converter) {
|
||||
super(null, converter.toType(), delegate.getTypeName(), delegate.getCastTypeName());
|
||||
super(
|
||||
null,
|
||||
converter.toType(),
|
||||
delegate.getTypeName(),
|
||||
delegate.getCastTypeName(),
|
||||
delegate.precision(),
|
||||
delegate.scale(),
|
||||
delegate.length(),
|
||||
delegate.nullable(),
|
||||
delegate.defaulted()
|
||||
);
|
||||
|
||||
this.delegate = delegate;
|
||||
this.converter = converter;
|
||||
|
||||
@ -222,11 +222,11 @@ public class DefaultDataType<T> implements DataType<T> {
|
||||
}
|
||||
|
||||
public DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, String typeName) {
|
||||
this(dialect, sqlDataType, sqlDataType.getType(), typeName, typeName, 0, 0, 0, sqlDataType.nullable(), sqlDataType.defaulted());
|
||||
this(dialect, sqlDataType, sqlDataType.getType(), typeName, typeName, sqlDataType.precision(), sqlDataType.scale(), sqlDataType.length(), sqlDataType.nullable(), sqlDataType.defaulted());
|
||||
}
|
||||
|
||||
public DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, String typeName, String castTypeName) {
|
||||
this(dialect, sqlDataType, sqlDataType.getType(), typeName, castTypeName, 0, 0, 0, sqlDataType.nullable(), sqlDataType.defaulted());
|
||||
this(dialect, sqlDataType, sqlDataType.getType(), typeName, castTypeName, sqlDataType.precision(), sqlDataType.scale(), sqlDataType.length(), sqlDataType.nullable(), sqlDataType.defaulted());
|
||||
}
|
||||
|
||||
public DefaultDataType(SQLDialect dialect, Class<T> type, String typeName) {
|
||||
@ -237,7 +237,11 @@ public class DefaultDataType<T> implements DataType<T> {
|
||||
this(dialect, null, type, typeName, castTypeName, 0, 0, 0, true, false);
|
||||
}
|
||||
|
||||
private DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, Class<T> type, String typeName, String castTypeName, int precision, int scale, int length, boolean nullable, boolean defaulted) {
|
||||
DefaultDataType(SQLDialect dialect, Class<T> type, String typeName, String castTypeName, int precision, int scale, int length, boolean nullable, boolean defaulted) {
|
||||
this(dialect, null, type, typeName, castTypeName, precision, scale, length, nullable, defaulted);
|
||||
}
|
||||
|
||||
DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, Class<T> type, String typeName, String castTypeName, int precision, int scale, int length, boolean nullable, boolean defaulted) {
|
||||
|
||||
// Initialise final instance members
|
||||
// ---------------------------------
|
||||
|
||||
Loading…
Reference in New Issue
Block a user