[#629] Add support for the Teradata database (WIP)
This commit is contained in:
parent
b23489e684
commit
2c6023ef3c
@ -58,6 +58,7 @@ import org.jooq.meta.sqlite.SQLiteDatabase;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* A common utility class that provides access to various {@link Database}
|
||||
@ -98,6 +99,7 @@ public class Databases {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case CUBRID: result = CUBRIDDatabase.class; break;
|
||||
|
||||
@ -48,15 +48,18 @@ public interface AlterTableRenameColumnToStep {
|
||||
/**
|
||||
* Specify a new column name.
|
||||
*/
|
||||
@Support
|
||||
AlterTableFinalStep to(Field<?> newName);
|
||||
|
||||
/**
|
||||
* Specify a new column name.
|
||||
*/
|
||||
@Support
|
||||
AlterTableFinalStep to(Name newName);
|
||||
|
||||
/**
|
||||
* Specify a new column name.
|
||||
*/
|
||||
@Support
|
||||
AlterTableFinalStep to(String newName);
|
||||
}
|
||||
@ -56,6 +56,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -46,6 +46,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* The step in the <code>COMMENT ON [ object type ]</code> statement where the
|
||||
|
||||
@ -55,6 +55,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
@ -53,6 +53,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* A {@link Query} that can create tables.
|
||||
|
||||
@ -62,6 +62,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.sql.Connection;
|
||||
|
||||
@ -55,6 +55,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
/**
|
||||
* A {@link Query} that can drop indexes.
|
||||
|
||||
@ -59,6 +59,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
@ -61,6 +61,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.asterisk;
|
||||
import static org.jooq.impl.DSL.falseCondition;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
|
||||
@ -65,6 +65,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.alterTable;
|
||||
import static org.jooq.impl.DSL.commentOnTable;
|
||||
import static org.jooq.impl.DSL.constraint;
|
||||
@ -98,6 +99,7 @@ import static org.jooq.impl.Keywords.K_MODIFY;
|
||||
import static org.jooq.impl.Keywords.K_NOT_NULL;
|
||||
import static org.jooq.impl.Keywords.K_NULL;
|
||||
import static org.jooq.impl.Keywords.K_RAISE;
|
||||
import static org.jooq.impl.Keywords.K_RENAME;
|
||||
import static org.jooq.impl.Keywords.K_RENAME_COLUMN;
|
||||
import static org.jooq.impl.Keywords.K_RENAME_CONSTRAINT;
|
||||
import static org.jooq.impl.Keywords.K_RENAME_INDEX;
|
||||
@ -176,7 +178,8 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
private static final EnumSet<SQLDialect> NO_SUPPORT_IF_EXISTS_COLUMN = EnumSet.of(CUBRID, DERBY, FIREBIRD);
|
||||
private static final EnumSet<SQLDialect> SUPPORT_RENAME_TABLE = EnumSet.of(DERBY);
|
||||
private static final EnumSet<SQLDialect> NO_SUPPORT_ALTER_TYPE_AND_NULL = EnumSet.of(POSTGRES);
|
||||
private static final EnumSet<SQLDialect> REQUIRE_REPEAT_KEYWORD_ON_MULTI_ALTER = EnumSet.of(FIREBIRD, MARIADB, MYSQL);
|
||||
private static final EnumSet<SQLDialect> REQUIRE_REPEAT_ADD_ON_MULTI_ALTER = EnumSet.of(FIREBIRD, MARIADB, MYSQL);
|
||||
private static final EnumSet<SQLDialect> REQUIRE_REPEAT_DROP_ON_MULTI_ALTER = EnumSet.of(FIREBIRD, MARIADB, MYSQL);
|
||||
|
||||
|
||||
|
||||
@ -826,6 +829,18 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
.qualify(qualify);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.qualify(false)
|
||||
.visit(K_RENAME_COLUMN).sql(' ')
|
||||
@ -882,13 +897,17 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
}
|
||||
else if (add != null) {
|
||||
boolean qualify = ctx.qualify();
|
||||
boolean multiAdd = REQUIRE_REPEAT_ADD_ON_MULTI_ALTER.contains(ctx.family());
|
||||
|
||||
ctx.start(ALTER_TABLE_ADD)
|
||||
.visit(K_ADD)
|
||||
.qualify(false)
|
||||
.sql(" (");
|
||||
.sql(' ');
|
||||
|
||||
boolean indent = add.size() > 1;
|
||||
if (!multiAdd)
|
||||
ctx.sql('(');
|
||||
|
||||
boolean indent = !multiAdd && add.size() > 1;
|
||||
|
||||
if (indent)
|
||||
ctx.formatIndentStart()
|
||||
@ -896,7 +915,10 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
|
||||
for (int i = 0; i < add.size(); i++) {
|
||||
if (i > 0)
|
||||
ctx.sql(',').formatSeparator();
|
||||
if (multiAdd)
|
||||
ctx.sql(',').formatSeparator().visit(K_ADD).sql(' ');
|
||||
else
|
||||
ctx.sql(',').formatSeparator();
|
||||
|
||||
FieldOrConstraint part = add.get(i);
|
||||
ctx.visit(part);
|
||||
@ -911,8 +933,10 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
ctx.formatIndentEnd()
|
||||
.formatNewLine();
|
||||
|
||||
ctx.sql(')')
|
||||
.qualify(qualify)
|
||||
if (!multiAdd)
|
||||
ctx.sql(')');
|
||||
|
||||
ctx.qualify(qualify)
|
||||
.end(ALTER_TABLE_ADD);
|
||||
}
|
||||
else if (addColumn != null) {
|
||||
@ -1085,7 +1109,7 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
else if (dropColumns != null) {
|
||||
ctx.start(ALTER_TABLE_DROP);
|
||||
|
||||
if (REQUIRE_REPEAT_KEYWORD_ON_MULTI_ALTER.contains(family)) {
|
||||
if (REQUIRE_REPEAT_DROP_ON_MULTI_ALTER.contains(family)) {
|
||||
String separator = "";
|
||||
|
||||
for (Field<?> dropColumn : dropColumns) {
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.nullSafe;
|
||||
import static org.jooq.impl.DSL.val;
|
||||
import static org.jooq.impl.Keywords.K_AND;
|
||||
@ -88,7 +89,7 @@ final class BetweenCondition<T> extends AbstractCondition implements BetweenAndS
|
||||
private static final Clause[] CLAUSES_BETWEEN_SYMMETRIC = { CONDITION, CONDITION_BETWEEN_SYMMETRIC };
|
||||
private static final Clause[] CLAUSES_NOT_BETWEEN = { CONDITION, CONDITION_NOT_BETWEEN };
|
||||
private static final Clause[] CLAUSES_NOT_BETWEEN_SYMMETRIC = { CONDITION, CONDITION_NOT_BETWEEN_SYMMETRIC };
|
||||
private static final EnumSet<SQLDialect> SUPPORTS_SYMMETRIC = EnumSet.of(CUBRID, DERBY, FIREBIRD, H2, MARIADB, MYSQL, SQLITE);
|
||||
private static final EnumSet<SQLDialect> NO_SUPPORT_SYMMETRIC = EnumSet.of(CUBRID, DERBY, FIREBIRD, H2, MARIADB, MYSQL, SQLITE);
|
||||
|
||||
private final boolean symmetric;
|
||||
private final boolean not;
|
||||
@ -115,9 +116,8 @@ final class BetweenCondition<T> extends AbstractCondition implements BetweenAndS
|
||||
this.maxValue = nullSafe(f, field.getDataType());
|
||||
return this;
|
||||
}
|
||||
else {
|
||||
else
|
||||
return super.and(f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,14 +131,12 @@ final class BetweenCondition<T> extends AbstractCondition implements BetweenAndS
|
||||
}
|
||||
|
||||
private final QueryPartInternal delegate(Configuration configuration) {
|
||||
if (symmetric && SUPPORTS_SYMMETRIC.contains(configuration.family())) {
|
||||
if (symmetric && NO_SUPPORT_SYMMETRIC.contains(configuration.family()))
|
||||
return not
|
||||
? (QueryPartInternal) field.notBetween(minValue, maxValue).and(field.notBetween(maxValue, minValue))
|
||||
: (QueryPartInternal) field.between(minValue, maxValue).or(field.between(maxValue, minValue));
|
||||
}
|
||||
else {
|
||||
else
|
||||
return new Native();
|
||||
}
|
||||
}
|
||||
|
||||
private class Native extends AbstractQueryPart {
|
||||
|
||||
@ -79,6 +79,9 @@ final class BitCount extends AbstractFunction<Integer> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Better solutions very welcome! See also:
|
||||
// See also http://stackoverflow.com/questions/7946349/how-to-simulate-the-mysql-bit-count-function-in-sybase-sql-anywhere
|
||||
case H2:
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.comment;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.Keywords.K_ALTER_TABLE;
|
||||
|
||||
@ -73,6 +73,7 @@ final class Cot extends AbstractFunction<BigDecimal> {
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
return function("cot", SQLDataType.NUMERIC, argument);
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.table;
|
||||
import static org.jooq.impl.Keywords.K_CREATE;
|
||||
@ -72,7 +73,6 @@ import org.jooq.Configuration;
|
||||
import org.jooq.Context;
|
||||
import org.jooq.CreateIndexIncludeStep;
|
||||
import org.jooq.CreateIndexStep;
|
||||
import org.jooq.CreateIndexWhereStep;
|
||||
import org.jooq.Field;
|
||||
import org.jooq.Index;
|
||||
import org.jooq.Name;
|
||||
@ -90,8 +90,7 @@ final class CreateIndexImpl extends AbstractQuery implements
|
||||
|
||||
// Cascading interface implementations for CREATE INDEX behaviour
|
||||
CreateIndexStep,
|
||||
CreateIndexIncludeStep,
|
||||
CreateIndexWhereStep {
|
||||
CreateIndexIncludeStep {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
@ -268,6 +267,7 @@ final class CreateIndexImpl extends AbstractQuery implements
|
||||
.sql(' ');
|
||||
|
||||
boolean supportsInclude = false ;
|
||||
boolean supportsFieldsBeforeTable = false ;
|
||||
|
||||
QueryPartList<QueryPart> list = new QueryPartList<QueryPart>();
|
||||
if (fields != null)
|
||||
@ -278,14 +278,27 @@ final class CreateIndexImpl extends AbstractQuery implements
|
||||
if (!supportsInclude && include != null)
|
||||
list.addAll(asList(include));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.visit(K_ON)
|
||||
.sql(' ')
|
||||
.visit(table)
|
||||
.sql('(')
|
||||
.qualify(false)
|
||||
.visit(list)
|
||||
.qualify(true)
|
||||
.sql(')');
|
||||
.visit(table);
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.sql('(')
|
||||
.qualify(false)
|
||||
.visit(list)
|
||||
.qualify(true)
|
||||
.sql(')');
|
||||
|
||||
if (supportsInclude && include != null)
|
||||
ctx.formatSeparator()
|
||||
|
||||
@ -63,6 +63,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.commentOnTable;
|
||||
import static org.jooq.impl.DSL.createIndex;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
|
||||
@ -51,6 +51,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
import static org.jooq.impl.DSL.selectFrom;
|
||||
@ -175,14 +176,15 @@ final class CreateViewImpl<R extends Record> extends AbstractQuery implements
|
||||
// [#3835] SQLite doesn't like renaming columns at the view level
|
||||
boolean rename = fields != null && fields.length > 0;
|
||||
boolean renameSupported = ctx.family() != SQLITE;
|
||||
boolean replaceSupported = false ;
|
||||
|
||||
// [#4806] CREATE VIEW doesn't accept parameters in most databases
|
||||
ParamType paramType = ctx.paramType();
|
||||
|
||||
ctx.start(CREATE_VIEW_NAME)
|
||||
.visit(K_CREATE);
|
||||
.visit(replaceSupported && orReplace ? K_REPLACE : K_CREATE);
|
||||
|
||||
if (orReplace && !NO_SUPPORT_OR_REPLACE.contains(ctx.family())) {
|
||||
if (orReplace && !replaceSupported && !NO_SUPPORT_OR_REPLACE.contains(ctx.family())) {
|
||||
ctx.sql(' ').visit(K_OR);
|
||||
|
||||
switch (ctx.family()) {
|
||||
|
||||
@ -81,6 +81,7 @@ final class CurrentDate<T> extends AbstractFunction<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
|
||||
@ -73,6 +73,7 @@ final class CurrentTime<T> extends AbstractFunction<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case FIREBIRD:
|
||||
case HSQLDB:
|
||||
|
||||
@ -81,6 +81,7 @@ final class CurrentTimestamp<T> extends AbstractFunction<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
|
||||
@ -70,6 +70,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.Term.ROW_NUMBER;
|
||||
import static org.jooq.impl.Tools.EMPTY_FIELD;
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERYPART;
|
||||
@ -13048,7 +13049,7 @@ public class DSL {
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Field<String> translate(Field<String> text, Field<String> from, Field<String> to) {
|
||||
return function("translate", text.getDataType(), text, from, to);
|
||||
return new Translate(text, from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -58,6 +58,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INLINED;
|
||||
import static org.jooq.impl.DSL.cast;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
@ -1664,6 +1665,11 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else if (ctx.family() == POSTGRES)
|
||||
ctx.render()
|
||||
.sql("E'")
|
||||
|
||||
@ -59,8 +59,17 @@ final class Dual extends AbstractTable<Record> {
|
||||
|
||||
|
||||
|
||||
|
||||
static final String DUAL_HSQLDB = "select 1 as dual from information_schema.system_users limit 1";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static final Name DUAL_FIREBIRD = DSL.unquotedName("RDB$DATABASE");
|
||||
static final Name DUAL_CUBRID = DSL.unquotedName("db_root");
|
||||
static final Name DUAL_DERBY = DSL.unquotedName("SYSIBM", "SYSDUMMY1");
|
||||
|
||||
private final boolean force;
|
||||
|
||||
Dual() {
|
||||
@ -68,7 +77,7 @@ final class Dual extends AbstractTable<Record> {
|
||||
}
|
||||
|
||||
Dual(boolean force) {
|
||||
super("dual", (Schema) null);
|
||||
super(DSL.name("dual"), (Schema) null);
|
||||
|
||||
this.force = force;
|
||||
}
|
||||
@ -122,7 +131,7 @@ final class Dual extends AbstractTable<Record> {
|
||||
break;
|
||||
|
||||
case FIREBIRD:
|
||||
ctx.literal("RDB$DATABASE");
|
||||
ctx.visit(DUAL_FIREBIRD);
|
||||
break;
|
||||
|
||||
case HSQLDB:
|
||||
@ -130,7 +139,7 @@ final class Dual extends AbstractTable<Record> {
|
||||
break;
|
||||
|
||||
case CUBRID:
|
||||
ctx.literal("db_root");
|
||||
ctx.visit(DUAL_CUBRID);
|
||||
break;
|
||||
|
||||
// These dialects don't have a DUAL table. But emulation is needed
|
||||
@ -163,9 +172,7 @@ final class Dual extends AbstractTable<Record> {
|
||||
|
||||
|
||||
case DERBY:
|
||||
ctx.literal("SYSIBM")
|
||||
.sql('.')
|
||||
.literal("SYSDUMMY1");
|
||||
ctx.visit(DUAL_DERBY);
|
||||
break;
|
||||
|
||||
case MARIADB:
|
||||
|
||||
@ -54,6 +54,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.two;
|
||||
@ -165,35 +166,35 @@ final class Expression<T> extends AbstractFunction<T> {
|
||||
DSL.bitNot(DSL.bitAnd(lhsAsNumber(), rhsAsNumber())),
|
||||
DSL.bitOr(lhsAsNumber(), rhsAsNumber()));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Many dialects don't support shifts. Use multiplication/division instead
|
||||
else if (SHL == operator && EMULATE_SHR_SHL.contains(family)) {
|
||||
else if (SHL == operator && EMULATE_SHR_SHL.contains(family))
|
||||
return lhs.mul((Field<? extends Number>) DSL.power(two(), rhsAsNumber()).cast(lhs));
|
||||
}
|
||||
|
||||
// [#3962] This emulation is expensive. If this is emulated, BitCount should
|
||||
// use division instead of SHR directly
|
||||
else if (SHR == operator && EMULATE_SHR_SHL.contains(family)) {
|
||||
else if (SHR == operator && EMULATE_SHR_SHL.contains(family))
|
||||
return lhs.div((Field<? extends Number>) DSL.power(two(), rhsAsNumber()).cast(lhs));
|
||||
}
|
||||
|
||||
// Some dialects support shifts as functions
|
||||
else if (SHL == operator && FIREBIRD == family) {
|
||||
else if (SHL == operator && FIREBIRD == family)
|
||||
return function("bin_shl", getDataType(), getArguments());
|
||||
}
|
||||
else if (SHR == operator && FIREBIRD == family) {
|
||||
else if (SHR == operator && FIREBIRD == family)
|
||||
return function("bin_shr", getDataType(), getArguments());
|
||||
}
|
||||
|
||||
// These operators are not supported in any dialect
|
||||
else if (BIT_NAND == operator) {
|
||||
else if (BIT_NAND == operator)
|
||||
return (Field<T>) DSL.bitNot(DSL.bitAnd(lhsAsNumber(), rhsAsNumber()));
|
||||
}
|
||||
else if (BIT_NOR == operator) {
|
||||
else if (BIT_NOR == operator)
|
||||
return (Field<T>) DSL.bitNot(DSL.bitOr(lhsAsNumber(), rhsAsNumber()));
|
||||
}
|
||||
else if (BIT_XNOR == operator) {
|
||||
else if (BIT_XNOR == operator)
|
||||
return (Field<T>) DSL.bitNot(DSL.bitXor(lhsAsNumber(), rhsAsNumber()));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// XXX: Date time arithmetic operators
|
||||
@ -203,19 +204,16 @@ final class Expression<T> extends AbstractFunction<T> {
|
||||
else if ((ADD == operator || SUBTRACT == operator) &&
|
||||
lhs.getDataType().isDateTime() &&
|
||||
(rhs.get(0).getDataType().isNumeric() ||
|
||||
rhs.get(0).getDataType().isInterval())) {
|
||||
|
||||
rhs.get(0).getDataType().isInterval()))
|
||||
return new DateExpression();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// XXX: Other operators
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
// Use the default operator expression for all other cases
|
||||
else {
|
||||
else
|
||||
return new DefaultExpression();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -41,6 +41,7 @@ import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Map;
|
||||
|
||||
@ -137,12 +137,13 @@ final class FieldMapsForInsert extends AbstractQueryPart {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case FIREBIRD: {
|
||||
ctx.formatSeparator()
|
||||
.start(INSERT_SELECT);
|
||||
ctx.visit(insertSelect(ctx));
|
||||
ctx.visit(insertSelect());
|
||||
ctx.end(INSERT_SELECT);
|
||||
|
||||
break;
|
||||
@ -162,7 +163,7 @@ final class FieldMapsForInsert extends AbstractQueryPart {
|
||||
}
|
||||
}
|
||||
|
||||
private final Select<Record> insertSelect(Context<?> context) {
|
||||
private final Select<Record> insertSelect() {
|
||||
Select<Record> select = null;
|
||||
|
||||
for (int row = 0; row < rows; row++) {
|
||||
@ -171,7 +172,7 @@ final class FieldMapsForInsert extends AbstractQueryPart {
|
||||
for (List<Field<?>> list : values.values())
|
||||
fields.add(list.get(row));
|
||||
|
||||
Select<Record> iteration = DSL.using(context.configuration()).select(fields);
|
||||
Select<Record> iteration = DSL.select(fields);
|
||||
|
||||
if (select == null)
|
||||
select = iteration;
|
||||
|
||||
@ -366,6 +366,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
|
||||
|
||||
|
||||
|
||||
|
||||
case HSQLDB: {
|
||||
ctx.visit(toMerge(ctx.configuration()));
|
||||
break;
|
||||
@ -463,6 +464,7 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case HSQLDB: {
|
||||
|
||||
@ -78,6 +78,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.condition;
|
||||
import static org.jooq.impl.DSL.exists;
|
||||
import static org.jooq.impl.DSL.notExists;
|
||||
|
||||
@ -99,6 +99,7 @@ final class Ln extends AbstractFunction<BigDecimal> {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case H2:
|
||||
case HSQLDB:
|
||||
|
||||
@ -74,6 +74,7 @@ final class Mod<T> extends AbstractFunction<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
case SQLITE:
|
||||
return new Expression<T>(MODULO, arg1, arg2);
|
||||
}
|
||||
|
||||
@ -44,6 +44,7 @@ import static org.jooq.SQLDialect.HSQLDB;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.ExpressionOperator.BIT_NOT;
|
||||
|
||||
import java.util.EnumSet;
|
||||
@ -81,28 +82,24 @@ final class Neg<T> extends AbstractField<T> {
|
||||
public final void accept(Context<?> ctx) {
|
||||
SQLDialect family = ctx.configuration().dialect().family();
|
||||
|
||||
if (operator == BIT_NOT && EMULATE_BIT_NOT.contains(family)) {
|
||||
if (operator == BIT_NOT && EMULATE_BIT_NOT.contains(family))
|
||||
ctx.sql("(0 - ")
|
||||
.visit(field)
|
||||
.sql(" - 1)");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else if (operator == BIT_NOT && family == FIREBIRD) {
|
||||
else if (operator == BIT_NOT && family == FIREBIRD)
|
||||
ctx.sql("bin_not(")
|
||||
.visit(field)
|
||||
.sql(')');
|
||||
}
|
||||
else {
|
||||
else
|
||||
ctx.sql(operator.toSQL())
|
||||
.sql('(')
|
||||
.visit(field)
|
||||
.sql(')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -71,6 +71,7 @@ final class Repeat extends AbstractFunction<String> {
|
||||
|
||||
|
||||
|
||||
|
||||
case FIREBIRD:
|
||||
return DSL.rpad(string, DSL.length(string).mul(count), string);
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ import org.jooq.util.sqlite.SQLiteDataType;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
|
||||
|
||||
@ -596,6 +597,7 @@ public final class SQLDataType {
|
||||
|
||||
|
||||
|
||||
|
||||
Class.forName(CUBRIDDataType.class.getName());
|
||||
Class.forName(DerbyDataType.class.getName());
|
||||
Class.forName(FirebirdDataType.class.getName());
|
||||
|
||||
@ -81,6 +81,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SortOrder.DESC;
|
||||
import static org.jooq.impl.CombineOperator.EXCEPT;
|
||||
import static org.jooq.impl.CombineOperator.EXCEPT_ALL;
|
||||
|
||||
@ -67,6 +67,7 @@ final class Space extends AbstractFunction<String> {
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case FIREBIRD:
|
||||
case HSQLDB:
|
||||
|
||||
@ -63,7 +63,10 @@ final class Substring extends AbstractFunction<String> {
|
||||
|
||||
switch (configuration.family()) {
|
||||
|
||||
// [#430] Firebird has its own syntax
|
||||
// [#430] These databases use SQL standard syntax
|
||||
|
||||
|
||||
|
||||
case FIREBIRD: {
|
||||
if (getArguments().length == 2) {
|
||||
return DSL.field("{substring}({0} {from} {1})", SQLDataType.VARCHAR, getArguments());
|
||||
|
||||
@ -73,6 +73,10 @@ final class WidthBucket<T extends Number> extends AbstractField<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES:
|
||||
ctx.visit(DSL.field("{width_bucket}({0}, {1}, {2}, {3})", getType(), field, low, high, buckets));
|
||||
break;
|
||||
|
||||
@ -75,6 +75,7 @@ import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
|
||||
import java.sql.Array;
|
||||
import java.sql.Blob;
|
||||
@ -261,9 +262,8 @@ public class JDBCUtils {
|
||||
* "Guess" the {@link SQLDialect} from a connection URL.
|
||||
*/
|
||||
public static final SQLDialect dialect(String url) {
|
||||
if (url == null) {
|
||||
if (url == null)
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
// The below list might not be accurate or complete. Feel free to
|
||||
// contribute fixes related to new / different JDBC driver configurations
|
||||
@ -281,44 +281,27 @@ public class JDBCUtils {
|
||||
|
||||
|
||||
|
||||
|
||||
else if (url.contains(":cubrid:")) {
|
||||
else if (url.contains(":cubrid:"))
|
||||
return CUBRID;
|
||||
}
|
||||
else if (url.contains(":derby:")) {
|
||||
else if (url.contains(":derby:"))
|
||||
return DERBY;
|
||||
}
|
||||
else if (url.contains(":firebirdsql:")) {
|
||||
else if (url.contains(":firebirdsql:"))
|
||||
return FIREBIRD;
|
||||
}
|
||||
else if (url.contains(":h2:")) {
|
||||
else if (url.contains(":h2:"))
|
||||
return H2;
|
||||
}
|
||||
else if (url.contains(":hsqldb:")) {
|
||||
else if (url.contains(":hsqldb:"))
|
||||
return HSQLDB;
|
||||
}
|
||||
else if (url.contains(":mariadb:")) {
|
||||
else if (url.contains(":mariadb:"))
|
||||
return MARIADB;
|
||||
}
|
||||
else if (url.contains(":mysql:")
|
||||
|| url.contains(":google:")) {
|
||||
|| url.contains(":google:"))
|
||||
return MYSQL;
|
||||
}
|
||||
else if (url.contains(":postgresql:")
|
||||
|| url.contains(":pgsql:")) {
|
||||
|| url.contains(":pgsql:"))
|
||||
return POSTGRES;
|
||||
}
|
||||
else if (url.contains(":sqlite:")
|
||||
|| url.contains(":sqldroid:")) {
|
||||
|| url.contains(":sqldroid:"))
|
||||
return SQLITE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -393,6 +376,8 @@ public class JDBCUtils {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user