[jOOQ/jOOQ#9650] SNOWFLAKE support WIP
This commit is contained in:
parent
d17ef85707
commit
8cce50893e
@ -63,6 +63,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQL99;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
@ -171,6 +172,7 @@ public @interface Allow {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CUBRID,
|
||||
DEFAULT,
|
||||
|
||||
@ -105,7 +105,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final AlterDatabaseImpl renameTo(String renameTo) {
|
||||
return renameTo(DSL.catalog(DSL.name(renameTo)));
|
||||
|
||||
@ -162,7 +162,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final AlterDomainImpl<T> add(Constraint addConstraint) {
|
||||
this.addConstraint = addConstraint;
|
||||
|
||||
@ -105,7 +105,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final AlterSchemaImpl renameTo(String renameTo) {
|
||||
return renameTo(DSL.schema(DSL.name(renameTo)));
|
||||
|
||||
@ -109,8 +109,7 @@ implements
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final AlterViewImpl comment(String comment) {
|
||||
return comment(DSL.comment(comment));
|
||||
|
||||
@ -111,7 +111,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final CommentOnImpl is(String comment) {
|
||||
return is(DSL.comment(comment));
|
||||
|
||||
@ -117,7 +117,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final <T> CreateDomainImpl<T> as(Class<T> dataType) {
|
||||
return as(DefaultDataType.getDataType(null, dataType));
|
||||
|
||||
@ -150,7 +150,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final CreateSequenceImpl startWith(Number startWith) {
|
||||
return startWith(Tools.field(startWith, sequence.getDataType()));
|
||||
|
||||
@ -15286,6 +15286,60 @@ public class DSL {
|
||||
return charLength(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LN</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> ln(Number value) {
|
||||
return new Log(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LN</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> ln(Field<? extends Number> value) {
|
||||
return new Log(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LOG</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Number value, int base) {
|
||||
return new Log(Tools.field(value), Tools.field(base));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LOG</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Number value, Field<? extends Number> base) {
|
||||
return new Log(Tools.field(value), base);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LOG</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Field<? extends Number> value, int base) {
|
||||
return new Log(value, Tools.field(base));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LOG</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Field<? extends Number> value, Field<? extends Number> base) {
|
||||
return new Log(value, base);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>LOWER</code> function.
|
||||
* <p>
|
||||
@ -15859,6 +15913,42 @@ public class DSL {
|
||||
return new Position(in, search);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>POWER</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Number value, Number exponent) {
|
||||
return new Power(Tools.field(value), Tools.field(exponent));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>POWER</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Number value, Field<? extends Number> exponent) {
|
||||
return new Power(Tools.field(value), exponent);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>POWER</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Field<? extends Number> value, Number exponent) {
|
||||
return new Power(value, Tools.field(exponent));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>POWER</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Field<? extends Number> value, Field<? extends Number> exponent) {
|
||||
return new Power(value, exponent);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>RAD</code> function.
|
||||
* <p>
|
||||
@ -16469,6 +16559,24 @@ public class DSL {
|
||||
return new Space(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SQRT</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sqrt(Number value) {
|
||||
return new Sqrt(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SQRT</code> function.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sqrt(Field<? extends Number> value) {
|
||||
return new Sqrt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>SPLIT_PART</code> function.
|
||||
* <p>
|
||||
@ -20701,141 +20809,6 @@ public class DSL {
|
||||
return trunc(Tools.field(number), inline(0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sqrt(field) function.
|
||||
*
|
||||
* @see #sqrt(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sqrt(Number value) {
|
||||
return sqrt(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the sqrt(field) function.
|
||||
* <p>
|
||||
* This renders the sqrt function where available:
|
||||
* <code><pre>sqrt([field])</pre></code> ... or emulates it elsewhere using
|
||||
* power (which in turn may also be emulated using ln and exp functions):
|
||||
* <code><pre>power([field], 0.5)</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> sqrt(Field<? extends Number> field) {
|
||||
return new Sqrt(Tools.nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ln(field) function, taking the natural logarithm of this field.
|
||||
*
|
||||
* @see #ln(Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> ln(Number value) {
|
||||
return ln(Tools.field(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ln(field) function, taking the natural logarithm of this field.
|
||||
* <p>
|
||||
* This renders the ln or log function where available:
|
||||
* <code><pre>ln([field]) or
|
||||
* log([field])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> ln(Field<? extends Number> field) {
|
||||
return new Ln(Tools.nullSafe(field));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log(field, base) function.
|
||||
*
|
||||
* @see #log(Field, int)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Number value, int base) {
|
||||
return log(Tools.field(value), base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log(field, base) function.
|
||||
* <p>
|
||||
* This renders the log function where available:
|
||||
* <code><pre>log([field])</pre></code> ... or emulates it elsewhere (in
|
||||
* most RDBMS) using the natural logarithm:
|
||||
* <code><pre>ln([field]) / ln([base])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Field<? extends Number> field, int base) {
|
||||
return new Ln(Tools.nullSafe(field), Tools.field(base));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the log(field, base) function.
|
||||
* <p>
|
||||
* This renders the log function where available:
|
||||
* <code><pre>log([field])</pre></code> ... or emulates it elsewhere (in
|
||||
* most RDBMS) using the natural logarithm:
|
||||
* <code><pre>ln([field]) / ln([base])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> log(Field<? extends Number> field, Field<? extends Number> base) {
|
||||
return new Ln(Tools.nullSafe(field), base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power(field, exponent) function.
|
||||
*
|
||||
* @see #power(Field, Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Number value, Number exponent) {
|
||||
return power(Tools.field(value), Tools.field(exponent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power(field, exponent) function.
|
||||
*
|
||||
* @see #power(Field, Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Field<? extends Number> field, Number exponent) {
|
||||
return power(Tools.nullSafe(field), Tools.field(exponent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power(field, exponent) function.
|
||||
*
|
||||
* @see #power(Field, Field)
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Number value, Field<? extends Number> exponent) {
|
||||
return power(Tools.field(value), Tools.nullSafe(exponent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the power(field, exponent) function.
|
||||
* <p>
|
||||
* This renders the power function where available:
|
||||
* <code><pre>power([field], [exponent])</pre></code> ... or emulates it
|
||||
* elsewhere using ln and exp:
|
||||
* <code><pre>exp(ln([field]) * [exponent])</pre></code>
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES })
|
||||
public static Field<BigDecimal> power(Field<? extends Number> field, Field<? extends Number> exponent) {
|
||||
return new Power(Tools.nullSafe(field), Tools.nullSafe(exponent));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the arc cosine(field) function.
|
||||
*
|
||||
|
||||
@ -105,7 +105,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final DropDomainImpl cascade() {
|
||||
this.cascade = true;
|
||||
|
||||
@ -105,7 +105,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final DropSchemaImpl cascade() {
|
||||
this.cascade = true;
|
||||
|
||||
@ -116,7 +116,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final GrantImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
|
||||
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* 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.impl.DSL.function;
|
||||
import static org.jooq.impl.Internal.idiv;
|
||||
import static org.jooq.impl.Names.N_LN;
|
||||
import static org.jooq.impl.Names.N_LOG;
|
||||
import static org.jooq.impl.Names.N_LOGN;
|
||||
import static org.jooq.impl.SQLDataType.NUMERIC;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class Ln extends AbstractField<BigDecimal> {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
|
||||
private final Field<? extends Number> argument;
|
||||
private final Field<? extends Number> base;
|
||||
|
||||
Ln(Field<? extends Number> argument) {
|
||||
this(argument, null);
|
||||
}
|
||||
|
||||
Ln(Field<? extends Number> argument, Field<? extends Number> base) {
|
||||
super(N_LN, NUMERIC);
|
||||
|
||||
this.argument = argument;
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (base == null) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_LN, NUMERIC, argument));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case HSQLDB:
|
||||
ctx.visit(idiv(DSL.ln(argument), DSL.ln(base)));
|
||||
return;
|
||||
|
||||
default:
|
||||
ctx.visit(function(N_LOG, NUMERIC, base, argument));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,6 +55,7 @@ import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.insertInto;
|
||||
|
||||
@ -37,35 +37,56 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Internal.imul;
|
||||
import static org.jooq.impl.Names.N_POWER;
|
||||
import static org.jooq.impl.SQLDataType.NUMERIC;
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>POWER</code> statement.
|
||||
*/
|
||||
final class Power extends AbstractField<BigDecimal> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Power
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> arg1;
|
||||
private final Field<? extends Number> arg2;
|
||||
private final Field<? extends Number> value;
|
||||
private final Field<? extends Number> exponent;
|
||||
|
||||
Power(Field<? extends Number> arg1, Field<? extends Number> arg2) {
|
||||
super(N_POWER, NUMERIC);
|
||||
Power(
|
||||
Field<? extends Number> value,
|
||||
Field<? extends Number> exponent
|
||||
) {
|
||||
super(
|
||||
N_POWER,
|
||||
allNotNull(NUMERIC, value, exponent)
|
||||
);
|
||||
|
||||
this.arg1 = arg1;
|
||||
this.arg2 = arg2;
|
||||
this.value = nullSafeNotNull(value, INTEGER);
|
||||
this.exponent = nullSafeNotNull(exponent, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -77,12 +98,30 @@ final class Power extends AbstractField<BigDecimal> {
|
||||
|
||||
case DERBY:
|
||||
case SQLITE:
|
||||
ctx.visit(DSL.exp(imul(DSL.ln(arg1), arg2)));
|
||||
ctx.visit(DSL.exp(imul(DSL.ln(value), exponent)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(N_POWER).sql('(').visit(arg1).sql(", ").visit(arg2).sql(')');
|
||||
ctx.visit(N_POWER).sql('(').visit(value).sql(", ").visit(exponent).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Power) {
|
||||
return
|
||||
StringUtils.equals(value, ((Power) that).value) &&
|
||||
StringUtils.equals(exponent, ((Power) that).exponent)
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,6 @@ implements
|
||||
// XXX: DSL API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@Override
|
||||
public final RevokeImpl on(String on) {
|
||||
return on(DSL.table(DSL.name(on)));
|
||||
|
||||
@ -37,33 +37,53 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.Names.N_SQR;
|
||||
import static org.jooq.impl.Names.N_SQRT;
|
||||
import static org.jooq.impl.SQLDataType.NUMERIC;
|
||||
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.*;
|
||||
import org.jooq.impl.*;
|
||||
import org.jooq.tools.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.jooq.Context;
|
||||
import org.jooq.Field;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
* The <code>SQRT</code> statement.
|
||||
*/
|
||||
final class Sqrt extends AbstractField<BigDecimal> {
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class Sqrt
|
||||
extends
|
||||
AbstractField<BigDecimal>
|
||||
{
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -7273879239726265322L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Field<? extends Number> argument;
|
||||
private final Field<? extends Number> value;
|
||||
|
||||
Sqrt(Field<? extends Number> argument) {
|
||||
super(N_SQRT, NUMERIC);
|
||||
Sqrt(
|
||||
Field<? extends Number> value
|
||||
) {
|
||||
super(
|
||||
N_SQRT,
|
||||
allNotNull(NUMERIC, value)
|
||||
);
|
||||
|
||||
this.argument = argument;
|
||||
this.value = nullSafeNotNull(value, INTEGER);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
@ -83,12 +103,29 @@ final class Sqrt extends AbstractField<BigDecimal> {
|
||||
|
||||
|
||||
case SQLITE:
|
||||
ctx.visit(DSL.power(argument, 0.5));
|
||||
ctx.visit(DSL.power(value, inline(0.5)));
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.visit(N_SQRT).sql('(').visit(argument).sql(')');
|
||||
ctx.visit(N_SQRT).sql('(').visit(value).sql(')');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof Sqrt) {
|
||||
return
|
||||
StringUtils.equals(value, ((Sqrt) that).value)
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user