diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 0cfb8def86..35ed5a19e2 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -15721,6 +15721,78 @@ public class DSL { return new Substring(string, startingPosition); } + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(String string, String from, String to) { + return new Translate(Tools.field(string), Tools.field(from), Tools.field(to)); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(String string, String from, Field to) { + return new Translate(Tools.field(string), Tools.field(from), to); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(String string, Field from, String to) { + return new Translate(Tools.field(string), from, Tools.field(to)); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(String string, Field from, Field to) { + return new Translate(Tools.field(string), from, to); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(Field string, String from, String to) { + return new Translate(string, Tools.field(from), Tools.field(to)); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(Field string, String from, Field to) { + return new Translate(string, Tools.field(from), to); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(Field string, Field from, String to) { + return new Translate(string, from, Tools.field(to)); + } + + /** + * The TRANSLATE function. + */ + @NotNull + @Support({ H2, HSQLDB, POSTGRES }) + public static Field translate(Field string, Field from, Field to) { + return new Translate(string, from, to); + } + /** * The TRIM function. */ @@ -15817,26 +15889,6 @@ public class DSL { return lpad(field, length, Character.toString(character)); } - /** - * Get the translate(field, from, to) function. - * - * @see #translate(Field, Field, Field) - */ - @NotNull - @Support({ H2, HSQLDB, POSTGRES }) - public static Field translate(Field text, String from, String to) { - return translate(text, Tools.field(from), Tools.field(to)); - } - - /** - * Get the translate(field, from, to) function. - */ - @NotNull - @Support({ H2, HSQLDB, POSTGRES }) - public static Field translate(Field text, Field from, Field to) { - return new Translate(text, from, to); - } - /** * Get the SQL Server specific SPACE() function. *

diff --git a/jOOQ/src/main/java/org/jooq/impl/Translate.java b/jOOQ/src/main/java/org/jooq/impl/Translate.java index 48841bf85c..c5756b22fc 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Translate.java +++ b/jOOQ/src/main/java/org/jooq/impl/Translate.java @@ -37,34 +37,53 @@ */ package org.jooq.impl; -import static org.jooq.impl.DSL.function; -import static org.jooq.impl.Names.N_TRANSLATE; +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 org.jooq.Context; -import org.jooq.Field; +import org.jooq.*; +import org.jooq.impl.*; + +import java.util.*; /** - * @author Lukas Eder + * The TRANSLATE statement. */ -final class Translate extends AbstractField { +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class Translate +extends + AbstractField +{ - /** - * Generated UID - */ - private static final long serialVersionUID = 6776882414592454999L; + private static final long serialVersionUID = 1L; - private final Field text; + private final Field string; private final Field from; private final Field to; - Translate(Field text, Field from, Field to) { - super(N_TRANSLATE, text.getDataType()); + Translate( + Field string, + Field from, + Field to + ) { + super(N_TRANSLATE, allNotNull(VARCHAR, string, from, to)); - this.text = text; - this.from = from; - this.to = to; + this.string = nullSafeNotNull(string, VARCHAR); + this.from = nullSafeNotNull(from, VARCHAR); + this.to = nullSafeNotNull(to, VARCHAR); } + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + @Override public final void accept(Context ctx) { switch (ctx.family()) { @@ -79,8 +98,10 @@ final class Translate extends AbstractField { default: - ctx.visit(function("translate", getDataType(), text, from, to)); + ctx.visit(function("translate", getDataType(), string, from, to)); return; } } + + }