diff --git a/jOOQ/src/main/java/org/jooq/impl/Cbrt.java b/jOOQ/src/main/java/org/jooq/impl/Cbrt.java new file mode 100644 index 0000000000..146b02e94a --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Cbrt.java @@ -0,0 +1,211 @@ +/* + * 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 + * + * https://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: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +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.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; +import java.math.BigDecimal; + + +/** + * The CBRT statement. + */ +@SuppressWarnings({ "rawtypes", "unused" }) +final class Cbrt +extends + AbstractField +implements + QOM.Cbrt +{ + + final Field value; + + Cbrt( + Field value + ) { + super( + N_CBRT, + allNotNull(NUMERIC, value) + ); + + this.value = nullSafeNotNull(value, INTEGER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + final boolean parenthesised(Context ctx) { + switch (ctx.family()) { + + + + + + + + + + + + + + + case CUBRID: + case DERBY: + case FIREBIRD: + case H2: + case HSQLDB: + case IGNITE: + case MARIADB: + case MYSQL: + case SQLITE: + return false; + + default: + return true; + } + } + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + + + + + + + + + + + + + + + case CUBRID: + case DERBY: + case FIREBIRD: + case H2: + case HSQLDB: + case IGNITE: + case MARIADB: + case MYSQL: + case SQLITE: + ctx.visit(DSL.root(value, inline(3.0))); + break; + + default: + ctx.visit(function(N_CBRT, getDataType(), value)); + break; + } + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return value; + } + + @Override + public final QOM.Cbrt $arg1(Field newValue) { + return $constructor().apply(newValue); + } + + @Override + public final Function1, ? extends QOM.Cbrt> $constructor() { + return (a1) -> new Cbrt(a1); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.Cbrt o) { + return + StringUtils.equals($value(), o.$value()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index ba0bc7485f..61c461b214 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -18326,6 +18326,26 @@ public class DSL { return new BitXor<>(arg1, arg2); } + /** + * The CBRT function. + * + * @param value is wrapped as {@link DSL#val(Object)}. + */ + @NotNull + @Support + public static Field cbrt(Number value) { + return new Cbrt(Tools.field(value)); + } + + /** + * The CBRT function. + */ + @NotNull + @Support + public static Field cbrt(Field value) { + return new Cbrt(value); + } + /** * The CEIL function. *

@@ -18701,6 +18721,49 @@ public class DSL { return new Rand(); } + /** + * The ROOT function. + * + * @param value is wrapped as {@link DSL#val(Object)}. + * @param degree is wrapped as {@link DSL#val(Object)}. + */ + @NotNull + @Support + public static Field root(Number value, Number degree) { + return new Root(Tools.field(value), Tools.field(degree)); + } + + /** + * The ROOT function. + * + * @param value is wrapped as {@link DSL#val(Object)}. + */ + @NotNull + @Support + public static Field root(Number value, Field degree) { + return new Root(Tools.field(value), degree); + } + + /** + * The ROOT function. + * + * @param degree is wrapped as {@link DSL#val(Object)}. + */ + @NotNull + @Support + public static Field root(Field value, Number degree) { + return new Root(value, Tools.field(degree)); + } + + /** + * The ROOT function. + */ + @NotNull + @Support + public static Field root(Field value, Field degree) { + return new Root(value, degree); + } + /** * The ROUND function. *

diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 9391c61584..f983d825e5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -404,6 +404,7 @@ final class Names { static final Name N_BOOL_OR = systemName("bool_or"); static final Name N_BYTE_LENGTH = systemName("byte_length"); static final Name N_CARDINALITY = systemName("cardinality"); + static final Name N_CBRT = systemName("cbrt"); static final Name N_CEIL = systemName("ceil"); static final Name N_CEILING = systemName("ceiling"); static final Name N_CHAR = systemName("char"); @@ -534,6 +535,7 @@ final class Names { static final Name N_RETURN_ = systemName("return_"); static final Name N_REVERSE = systemName("reverse"); static final Name N_RIGHT = systemName("right"); + static final Name N_ROOT = systemName("root"); static final Name N_ROUND = systemName("round"); static final Name N_ROWNUM = systemName("rownum"); static final Name N_RPAD = systemName("rpad"); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index a64abfcc4e..50b4f3fe35 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -8813,6 +8813,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { return coth((Field) parseFieldNumericOpParenthesised()); else if (parseFunctionNameIf("COT")) return cot((Field) parseFieldNumericOpParenthesised()); + else if (parseFunctionNameIf("CBRT")) + return parseFunctionArgs1(DSL::cbrt); else if (parseFunctionNameIf("CONTAINS")) return parseFunctionArgs2((f1, f2) -> f1.contains(f2)); else if ((field = parseNextvalCurrvalIf(SequenceMethod.CURRVAL)) != null) @@ -9265,6 +9267,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { return parseFunctionArgs1(f -> parseWindowFunction(null, null, ratioToReport(f))); else if (parseKeywordIf("RSHIFT", "RIGHT_SHIFT")) return parseFunctionArgs2(() -> toField(parseNumericOp()), (f1, f2) -> shr(f1, f2)); + else if (parseFunctionNameIf("ROOT")) + return parseFunctionArgs2(DSL::sqrt, DSL::root); else if (parseFunctionNameIf("ROW")) return parseTuple(); diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index fdcfc3d934..29789aae5f 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -7052,6 +7052,42 @@ public final class QOM { // BitXor {} + /** + * The CBRT function. + */ + public static final Cbrt Cbrt() { + return new org.jooq.impl.Cbrt( + null + ); + } + + /** + * The CBRT function. + */ + public static final Cbrt Cbrt( + Field value + ) { + return new org.jooq.impl.Cbrt( + value + ); + } + + /** + * The CBRT function. + */ + public /*sealed*/ interface Cbrt + extends + UReturnsNullOnNullInput, + UOperator1, Cbrt>, + org.jooq.Field + //permits + // Cbrt + { + @NotNull default Field $value() { return $arg1(); } + @CheckReturnValue + @NotNull default Cbrt $value(Field newValue) { return $arg1(newValue); } + } + /** * The CEIL function. *

@@ -7771,6 +7807,48 @@ public final class QOM { // Rand {} + /** + * The ROOT function. + */ + public static final Root Root() { + return new org.jooq.impl.Root( + null, + null + ); + } + + /** + * The ROOT function. + */ + public static final Root Root( + Field value, + Field degree + ) { + return new org.jooq.impl.Root( + value, + degree + ); + } + + /** + * The ROOT function. + */ + public /*sealed*/ interface Root + extends + UReturnsNullOnNullInput, + UOperator2, Field, Root>, + org.jooq.Field + //permits + // Root + { + @NotNull default Field $value() { return $arg1(); } + @CheckReturnValue + @NotNull default Root $value(Field newValue) { return $arg1(newValue); } + @NotNull default Field $degree() { return $arg2(); } + @CheckReturnValue + @NotNull default Root $degree(Field newDegree) { return $arg2(newDegree); } + } + /** * The ROUND function. *

diff --git a/jOOQ/src/main/java/org/jooq/impl/Root.java b/jOOQ/src/main/java/org/jooq/impl/Root.java new file mode 100644 index 0000000000..93e04583c2 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/Root.java @@ -0,0 +1,225 @@ +/* + * 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 + * + * https://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: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +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.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; +import java.math.BigDecimal; + + +/** + * The ROOT statement. + */ +@SuppressWarnings({ "rawtypes", "unused" }) +final class Root +extends + AbstractField +implements + QOM.Root +{ + + final Field value; + final Field degree; + + Root( + Field value, + Field degree + ) { + super( + N_ROOT, + allNotNull(NUMERIC, value, degree) + ); + + this.value = nullSafeNotNull(value, INTEGER); + this.degree = nullSafeNotNull(degree, INTEGER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + final boolean parenthesised(Context ctx) { + switch (ctx.family()) { + + + + + + + + + + + + + + case CUBRID: + case DERBY: + case FIREBIRD: + case H2: + case HSQLDB: + case IGNITE: + case MARIADB: + case MYSQL: + case SQLITE: + return false; + + default: + return true; + } + } + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + + + + + + + + + + + + + + case CUBRID: + case DERBY: + case FIREBIRD: + case H2: + case HSQLDB: + case IGNITE: + case MARIADB: + case MYSQL: + case SQLITE: + ctx.visit(DSL.power(value, idiv(inline(1.0), degree))); + break; + + default: + ctx.visit(function(N_ROOT, getDataType(), value, degree)); + break; + } + } + + + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return value; + } + + @Override + public final Field $arg2() { + return degree; + } + + @Override + public final QOM.Root $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.Root $arg2(Field newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.Root> $constructor() { + return (a1, a2) -> new Root(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.Root o) { + return + StringUtils.equals($value(), o.$value()) && + StringUtils.equals($degree(), o.$degree()) + ; + } + else + return super.equals(that); + } +}