From c703a892481ba4f3318cbf1534a986bd7fff5afa Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 18 Mar 2022 14:44:19 +0100 Subject: [PATCH] [jOOQ/jOOQ#13306] Separate QOM.Ln (natural logarithm) from QOM.Log (logarithm with base) --- jOOQ/src/main/java/org/jooq/impl/DSL.java | 20 ++++- jOOQ/src/main/java/org/jooq/impl/Log.java | 82 +++++-------------- .../src/main/java/org/jooq/impl/Patterns.java | 9 ++ jOOQ/src/main/java/org/jooq/impl/QOM.java | 21 ++++- 4 files changed, 69 insertions(+), 63 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index a3a9aa5acd..568b1ca0be 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -16514,26 +16514,32 @@ public class DSL { /** * The LN function. + *

+ * Get the natural logarithm of a value. * * @param value is wrapped as {@link #val(Object)}. */ @NotNull @Support public static Field ln(Number value) { - return new Log(Tools.field(value)); + return new Ln(Tools.field(value)); } /** * The LN function. + *

+ * Get the natural logarithm of a value. */ @NotNull @Support public static Field ln(Field value) { - return new Log(value); + return new Ln(value); } /** * The LOG function. + *

+ * Get the logarithm of a value for a base. * * @param value is wrapped as {@link #val(Object)}. * @param base is wrapped as {@link #val(Object)}. @@ -16546,6 +16552,8 @@ public class DSL { /** * The LOG function. + *

+ * Get the logarithm of a value for a base. * * @param value is wrapped as {@link #val(Object)}. */ @@ -16557,6 +16565,8 @@ public class DSL { /** * The LOG function. + *

+ * Get the logarithm of a value for a base. * * @param base is wrapped as {@link #val(Object)}. */ @@ -16568,6 +16578,8 @@ public class DSL { /** * The LOG function. + *

+ * Get the logarithm of a value for a base. */ @NotNull @Support @@ -16577,6 +16589,8 @@ public class DSL { /** * The LOG10 function. + *

+ * Get the logarithm of a value for base 10. * * @param value is wrapped as {@link #val(Object)}. */ @@ -16588,6 +16602,8 @@ public class DSL { /** * The LOG10 function. + *

+ * Get the logarithm of a value for base 10. */ @NotNull @Support diff --git a/jOOQ/src/main/java/org/jooq/impl/Log.java b/jOOQ/src/main/java/org/jooq/impl/Log.java index f9bf98df8a..fde298170c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Log.java +++ b/jOOQ/src/main/java/org/jooq/impl/Log.java @@ -63,7 +63,7 @@ import java.math.BigDecimal; /** - * The LN statement. + * The LOG statement. */ @SuppressWarnings({ "rawtypes", "unused" }) final class Log @@ -76,24 +76,12 @@ implements final Field value; final Field base; - Log( - Field value - ) { - super( - N_LN, - allNotNull(NUMERIC, value) - ); - - this.value = nullSafeNotNull(value, INTEGER); - this.base = null; - } - Log( Field value, Field base ) { super( - N_LN, + N_LOG, allNotNull(NUMERIC, value, base) ); @@ -105,42 +93,9 @@ implements // XXX: QueryPart API // ------------------------------------------------------------------------- - - @Override public final void accept(Context ctx) { - if (base == null) { - switch (ctx.family()) { - - - - - - - - - - - - - - - - - - - - case SQLITE: - ctx.visit(function(N_LOG, NUMERIC, value)); - return; - - default: - ctx.visit(function(N_LN, NUMERIC, value)); - return; - } - } - else { - switch (ctx.family()) { + switch (ctx.family()) { @@ -167,17 +122,26 @@ implements - case DERBY: - case HSQLDB: - case IGNITE: - case SQLITE: - ctx.visit(idiv(DSL.ln(value), DSL.ln(base))); - return; - default: - ctx.visit(function(N_LOG, NUMERIC, base, value)); - return; - } + + + + case DERBY: + case HSQLDB: + case IGNITE: + case SQLITE: + ctx.visit(idiv(DSL.ln(value), DSL.ln(base))); + break; + + + + + + + + default: + ctx.visit(function(N_LOG, NUMERIC, base, value)); + break; } } @@ -194,8 +158,6 @@ implements - - // ------------------------------------------------------------------------- // XXX: Query Object Model // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/Patterns.java b/jOOQ/src/main/java/org/jooq/impl/Patterns.java index f47dfd6eae..22129ba5be 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Patterns.java +++ b/jOOQ/src/main/java/org/jooq/impl/Patterns.java @@ -1460,6 +1460,15 @@ package org.jooq.impl; + + + + + + + + + diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index 015befcb72..f0921205db 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -2605,6 +2605,23 @@ public final class QOM { /** * The LN function. + *

+ * Get the natural logarithm of a value. + */ + public /*sealed*/ interface Ln + extends + org.jooq.Field + //permits + // Ln + { + @NotNull Field $value(); + @NotNull Ln $value(Field value); + } + + /** + * The LOG function. + *

+ * Get the logarithm of a value for a base. */ public /*sealed*/ interface Log extends @@ -2613,13 +2630,15 @@ public final class QOM { // Log { @NotNull Field $value(); - @Nullable Field $base(); + @NotNull Field $base(); @NotNull Log $value(Field value); @NotNull Log $base(Field base); } /** * The LOG10 function. + *

+ * Get the logarithm of a value for base 10. */ public /*sealed*/ interface Log10 extends