From a5453514061905ba0c47699307a686ffca0ef2bd Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 4 Dec 2020 14:37:21 +0100 Subject: [PATCH] [jOOQ/jOOQ#11061] Delay application of nullability of DataTypeProxy A the time a condition is formed from FieldProxy components that reference DataTypeProxy, the data type is not yet known, so making it nullable must be a proxied, delaying operation as well. --- .../java/org/jooq/impl/AbstractDataTypeX.java | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 jOOQ/src/main/java/org/jooq/impl/AbstractDataTypeX.java diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractDataTypeX.java b/jOOQ/src/main/java/org/jooq/impl/AbstractDataTypeX.java new file mode 100644 index 0000000000..30d7bdc759 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractDataTypeX.java @@ -0,0 +1,117 @@ +/* + * 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. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: http://www.jooq.org/licenses + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.Nullability.NOT_NULL; + +import org.jooq.CharacterSet; +import org.jooq.Collation; +import org.jooq.Comment; +import org.jooq.DataType; +import org.jooq.Field; +import org.jooq.Name; +import org.jooq.Nullability; + +/** + * @author Lukas Eder + */ +abstract class AbstractDataTypeX extends AbstractDataType { + + /** + * Generated UID + */ + private static final long serialVersionUID = 4155588654449505119L; + + AbstractDataTypeX(Name name, Comment comment) { + super(name, comment); + } + + /** + * [#7811] Allow for subtypes to override the constructor + */ + abstract AbstractDataTypeX construct( + Integer newPrecision, + Integer newScale, + Integer newLength, + Nullability newNullability, + Collation newCollation, + CharacterSet newCharacterSet, + boolean newIdentity, + Field newDefaultValue + ); + + @Override + public final DataType nullability(Nullability n) { + return construct(precision0(), scale0(), length0(), n, collation(), characterSet(), n.nullable() ? false : identity(), defaultValue()); + } + + @Override + public final DataType collation(Collation c) { + return construct(precision0(), scale0(), length0(), nullability(), c, characterSet(), identity(), defaultValue()); + } + + @Override + public final DataType characterSet(CharacterSet c) { + return construct(precision0(), scale0(), length0(), nullability(), collation(), c, identity(), defaultValue()); + } + + @Override + public final DataType identity(boolean i) { + return construct(precision0(), scale0(), length0(), i ? NOT_NULL : nullability(), collation(), characterSet(), i, defaultValue()); + } + + @Override + public final DataType default_(Field d) { + return construct(precision0(), scale0(), length0(), nullability(), collation(), characterSet(), identity(), d); + } + + @Override + final AbstractDataTypeX precision1(Integer p, Integer s) { + return construct(p, s, length0(), nullability(), collation(), characterSet(), identity(), defaultValue()); + } + + @Override + final AbstractDataTypeX scale1(Integer s) { + return construct(precision0(), s, length0(), nullability(), collation(), characterSet(), identity(), defaultValue()); + } + + @Override + final AbstractDataTypeX length1(Integer l) { + return construct(precision0(), scale0(), l, nullability(), collation(), characterSet(), identity(), defaultValue()); + } +}