From c131c7cb88dfea1c30b0f6c9696f7e50ba6bb4d6 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 11 Dec 2020 09:07:17 +0100 Subject: [PATCH] [jOOQ/jOOQ#11061] [jOOQ/jOOQ#11070] [jOOQ/jOOQ#11091] OVERLAY --- jOOQ/src/main/java/org/jooq/impl/DSL.java | 72 +++++++------- jOOQ/src/main/java/org/jooq/impl/Overlay.java | 98 ++++++++++--------- 2 files changed, 88 insertions(+), 82 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 166034efc8..a641891b94 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -15288,6 +15288,42 @@ public class DSL { return new OctetLength(string); } + /** + * The OVERLAY function. + */ + @NotNull + @Support + public static Field overlay(Field in, String placing, Number startIndex, Number length) { + return new Overlay(in, Tools.field(placing), Tools.field(startIndex), Tools.field(length)); + } + + /** + * The OVERLAY function. + */ + @NotNull + @Support + public static Field overlay(Field in, Field placing, Field startIndex, Field length) { + return new Overlay(in, placing, startIndex, length); + } + + /** + * The OVERLAY function. + */ + @NotNull + @Support + public static Field overlay(Field in, String placing, Number startIndex) { + return new Overlay(in, Tools.field(placing), Tools.field(startIndex)); + } + + /** + * The OVERLAY function. + */ + @NotNull + @Support + public static Field overlay(Field in, Field placing, Field startIndex) { + return new Overlay(in, placing, startIndex); + } + /** * The POSITION function. */ @@ -16053,42 +16089,6 @@ public class DSL { return new RegexpReplace(field, Tools.nullSafe(pattern), Tools.nullSafe(replacement), false); } - /** - * Get the overlay(in, placing, startIndex) function. - */ - @NotNull - @Support - public static Field overlay(Field in, String placing, Number startIndex) { - return new Overlay(Tools.nullSafe(in), Tools.field(placing), Tools.field(startIndex)); - } - - /** - * Get the overlay(in, placing, startIndex) function. - */ - @NotNull - @Support - public static Field overlay(Field in, Field placing, Field startIndex) { - return new Overlay(Tools.nullSafe(in), Tools.nullSafe(placing), Tools.nullSafe(startIndex)); - } - - /** - * Get the overlay(in, placing, startIndex, length) function. - */ - @NotNull - @Support - public static Field overlay(Field in, String placing, Number startIndex, Number length) { - return new Overlay(Tools.nullSafe(in), Tools.field(placing), Tools.field(startIndex), Tools.field(length)); - } - - /** - * Get the overlay(in, placing, startIndex, length) function. - */ - @NotNull - @Support - public static Field overlay(Field in, Field placing, Field startIndex, Field length) { - return new Overlay(Tools.nullSafe(in), Tools.nullSafe(placing), Tools.nullSafe(startIndex), Tools.nullSafe(length)); - } - /** * Get the insert(in, startIndex, length, placing) function. */ diff --git a/jOOQ/src/main/java/org/jooq/impl/Overlay.java b/jOOQ/src/main/java/org/jooq/impl/Overlay.java index 3ba8dd4706..5d5894e6f1 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Overlay.java +++ b/jOOQ/src/main/java/org/jooq/impl/Overlay.java @@ -35,71 +35,75 @@ * * */ - package org.jooq.impl; -// ... -// ... -// ... -// ... -import static org.jooq.SQLDialect.DERBY; -import static org.jooq.SQLDialect.H2; -// ... -import static org.jooq.SQLDialect.HSQLDB; -// ... -// ... -import static org.jooq.SQLDialect.MARIADB; -// ... -import static org.jooq.SQLDialect.MYSQL; -// ... -// ... -// ... -import static org.jooq.SQLDialect.SQLITE; -// ... -// ... -// ... -import static org.jooq.impl.DSL.inline; -import static org.jooq.impl.Internal.iadd; -import static org.jooq.impl.Internal.isub; -import static org.jooq.impl.Keywords.K_FOR; -import static org.jooq.impl.Keywords.K_FROM; -import static org.jooq.impl.Keywords.K_PLACING; -import static org.jooq.impl.Names.N_INSERT; -import static org.jooq.impl.Names.N_OVERLAY; +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.SQLDialect.*; -import java.util.Set; +import org.jooq.*; +import org.jooq.impl.*; -import org.jooq.Context; -import org.jooq.Field; -import org.jooq.SQLDialect; +import java.math.*; +import java.util.*; /** - * @author Lukas Eder + * The OVERLAY statement. */ -final class Overlay extends AbstractField { +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Overlay +extends + AbstractField +{ - private static final long serialVersionUID = 3544690069533526544L; - private static final Set NO_SUPPORT = SQLDialect.supportedBy(DERBY, H2, HSQLDB, MARIADB, MYSQL, SQLITE); - private static final Set SUPPORT_INSERT = SQLDialect.supportedBy(MARIADB, MYSQL); + private static final long serialVersionUID = 1L; private final Field in; private final Field placing; private final Field startIndex; private final Field length; - Overlay(Field in, Field placing, Field startIndex) { - this(in, placing, startIndex, null); + Overlay( + Field in, + Field placing, + Field startIndex + ) { + super(N_OVERLAY, allNotNull(VARCHAR, in, placing, startIndex)); + + this.in = nullSafeNotNull(in, VARCHAR); + this.placing = nullSafeNotNull(placing, VARCHAR); + this.startIndex = nullSafeNotNull(startIndex, INTEGER); + this.length = null; } - Overlay(Field in, Field placing, Field startIndex, Field length) { - super(N_OVERLAY, in.getDataType()); + Overlay( + Field in, + Field placing, + Field startIndex, + Field length + ) { + super(N_OVERLAY, allNotNull(VARCHAR, in, placing, startIndex, length)); - this.in = in; - this.placing = placing; - this.startIndex = startIndex; - this.length = length; + this.in = nullSafeNotNull(in, VARCHAR); + this.placing = nullSafeNotNull(placing, VARCHAR); + this.startIndex = nullSafeNotNull(startIndex, INTEGER); + this.length = nullSafeNotNull(length, INTEGER); } + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + private static final Set NO_SUPPORT = SQLDialect.supportedBy(DERBY, H2, HSQLDB, MARIADB, MYSQL, SQLITE); + private static final Set SUPPORT_INSERT = SQLDialect.supportedBy(MARIADB, MYSQL); + @Override public final void accept(Context ctx) { Field l = length; @@ -146,4 +150,6 @@ final class Overlay extends AbstractField { } } } + + }