[#629] Add support for the Teradata database
This commit is contained in:
parent
3bbd66ca7c
commit
43f8f9a02d
@ -43,6 +43,7 @@ import static java.lang.Boolean.TRUE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.conf.ParamType.INDEXED;
|
||||
import static org.jooq.impl.Tools.EMPTY_CLAUSE;
|
||||
import static org.jooq.impl.Tools.EMPTY_QUERYPART;
|
||||
|
||||
@ -888,7 +888,7 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
ctx.start(ALTER_TABLE_RENAME_CONSTRAINT);
|
||||
ctx.data(DATA_CONSTRAINT_REFERENCE, true);
|
||||
|
||||
if (family == HSQLDB) {
|
||||
if (family == HSQLDB)
|
||||
ctx.qualify(false)
|
||||
.visit(K_ALTER_CONSTRAINT).sql(' ')
|
||||
.visit(renameConstraint)
|
||||
@ -896,16 +896,14 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
.visit(K_RENAME_TO).sql(' ')
|
||||
.visit(renameConstraintTo)
|
||||
.qualify(qualify);
|
||||
}
|
||||
else {
|
||||
else
|
||||
ctx.qualify(false)
|
||||
.visit(K_RENAME_CONSTRAINT).sql(' ')
|
||||
.visit( K_RENAME_CONSTRAINT).sql(' ')
|
||||
.visit(renameConstraint)
|
||||
.formatSeparator()
|
||||
.visit(K_TO).sql(' ')
|
||||
.visit(renameConstraintTo)
|
||||
.qualify(qualify);
|
||||
}
|
||||
|
||||
ctx.data().remove(DATA_CONSTRAINT_REFERENCE);
|
||||
ctx.end(ALTER_TABLE_RENAME_CONSTRAINT);
|
||||
@ -1111,7 +1109,7 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
|
||||
|
||||
default:
|
||||
ctx.visit(K_SET_DEFAULT);
|
||||
ctx.sql(' ').visit(K_SET_DEFAULT);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -179,6 +179,9 @@ final class AlterViewImpl extends AbstractQuery implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
accept1(ctx);
|
||||
}
|
||||
|
||||
@ -201,6 +204,22 @@ final class AlterViewImpl extends AbstractQuery implements
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.impl.DSL.inline;
|
||||
import static org.jooq.impl.DSL.keyword;
|
||||
import static org.jooq.impl.DSL.sql;
|
||||
import static org.jooq.impl.SQLDataType.VARCHAR;
|
||||
|
||||
import java.sql.Date;
|
||||
|
||||
@ -272,6 +273,18 @@ final class DateAdd<T> extends AbstractFunction<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -70,9 +70,7 @@ final class Decode<T, Z> extends AbstractFunction<Z> {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
final Field<Z> getFunction0(Configuration configuration) {
|
||||
switch (configuration.dialect().family()) {
|
||||
|
||||
|
||||
switch (configuration.family()) {
|
||||
|
||||
|
||||
|
||||
@ -84,26 +82,22 @@ final class Decode<T, Z> extends AbstractFunction<Z> {
|
||||
|
||||
|
||||
// Other dialects emulate it with a CASE ... WHEN expression
|
||||
default: {
|
||||
default:
|
||||
CaseConditionStep<Z> when = DSL
|
||||
.decode()
|
||||
.choose()
|
||||
.when(field.isNotDistinctFrom(search), result);
|
||||
|
||||
for (int i = 0; i < more.length; i += 2) {
|
||||
for (int i = 0; i < more.length; i += 2)
|
||||
|
||||
// search/result pair
|
||||
if (i + 1 < more.length) {
|
||||
if (i + 1 < more.length)
|
||||
when = when.when(field.isNotDistinctFrom((Field<T>) more[i]), (Field<Z>) more[i + 1]);
|
||||
}
|
||||
|
||||
// trailing default value
|
||||
else {
|
||||
else
|
||||
return when.otherwise((Field<Z>) more[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return when;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,6 +560,7 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
|
||||
case POSTGRES: {
|
||||
return true;
|
||||
}
|
||||
@ -2677,6 +2678,8 @@ public class DefaultBinding<T, U> implements Binding<T, U> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// [#729] In the absence of the correct JDBC type, try setObject
|
||||
ctx.statement().setObject(ctx.index(), null);
|
||||
}
|
||||
|
||||
@ -459,6 +459,20 @@ final class Expression<T> extends AbstractFunction<T> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -594,7 +608,13 @@ final class Expression<T> extends AbstractFunction<T> {
|
||||
else
|
||||
return DSL.field("{datetime}({0}, {1})", getDataType(), lhs, rhsAsNumber().neg().concat(inline(" day")));
|
||||
|
||||
// These dialects can add / subtract days using +/- operators
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -50,6 +50,7 @@ import static org.jooq.SQLDialect.H2;
|
||||
import static org.jooq.SQLDialect.MARIADB;
|
||||
import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.constraint;
|
||||
import static org.jooq.impl.DSL.dual;
|
||||
import static org.jooq.impl.DSL.name;
|
||||
@ -552,6 +553,10 @@ final class InsertQueryImpl<R extends Record> extends AbstractStoreQuery<R> impl
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ctx.formatSeparator()
|
||||
.start(INSERT_SELECT)
|
||||
.visit(select)
|
||||
|
||||
@ -137,6 +137,7 @@ final class Keywords {
|
||||
static final Keyword K_FOLLOWING = keyword("following");
|
||||
static final Keyword K_FOR = keyword("for");
|
||||
static final Keyword K_FORALL = keyword("forall");
|
||||
static final Keyword K_FORMAT = keyword("format");
|
||||
static final Keyword K_FOR_SHARE = keyword("for share");
|
||||
static final Keyword K_FOR_UPDATE = keyword("for update");
|
||||
static final Keyword K_FOREIGN_KEY = keyword("foreign key");
|
||||
|
||||
@ -2137,7 +2137,9 @@ final class ParserImpl implements Parser {
|
||||
private static final DDLQuery parseAlterView(ParserContext ctx) {
|
||||
boolean ifExists = parseKeywordIf(ctx, "IF EXISTS");
|
||||
Table<?> oldName = parseTableName(ctx);
|
||||
parseKeyword(ctx, "RENAME TO");
|
||||
parseKeyword(ctx, "RENAME");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Table<?> newName = parseTableName(ctx);
|
||||
|
||||
return ifExists
|
||||
@ -2175,13 +2177,17 @@ final class ParserImpl implements Parser {
|
||||
? ctx.dsl.alterSequenceIfExists(sequenceName)
|
||||
: ctx.dsl.alterSequence(sequenceName);
|
||||
|
||||
if (parseKeywordIf(ctx, "RENAME TO"))
|
||||
if (parseKeywordIf(ctx, "RENAME")) {
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
return s1.renameTo(parseSequenceName(ctx));
|
||||
else if (parseKeywordIf(ctx, "RESTART"))
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "RESTART")) {
|
||||
if (parseKeywordIf(ctx, "WITH"))
|
||||
return s1.restartWith(parseUnsignedInteger(ctx));
|
||||
else
|
||||
return s1.restart();
|
||||
}
|
||||
else
|
||||
throw ctx.expected("RENAME TO", "RESTART");
|
||||
}
|
||||
@ -2833,28 +2839,31 @@ final class ParserImpl implements Parser {
|
||||
case 'r':
|
||||
case 'R':
|
||||
if (parseKeywordIf(ctx, "RENAME")) {
|
||||
if (parseKeywordIf(ctx, "TO")) {
|
||||
if (parseKeywordIf(ctx, "AS") || parseKeywordIf(ctx, "TO")) {
|
||||
Table<?> newName = parseTableName(ctx);
|
||||
|
||||
return s1.renameTo(newName);
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "COLUMN")) {
|
||||
Name oldName = parseIdentifier(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Name newName = parseIdentifier(ctx);
|
||||
|
||||
return s1.renameColumn(oldName).to(newName);
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "INDEX")) {
|
||||
Name oldName = parseIdentifier(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Name newName = parseIdentifier(ctx);
|
||||
|
||||
return s1.renameIndex(oldName).to(newName);
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "CONSTRAINT")) {
|
||||
Name oldName = parseIdentifier(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Name newName = parseIdentifier(ctx);
|
||||
|
||||
return s1.renameConstraint(oldName).to(newName);
|
||||
@ -3009,7 +3018,7 @@ final class ParserImpl implements Parser {
|
||||
return s1.alter(field).dropNotNull();
|
||||
else if (parseKeywordIf(ctx, "SET NOT NULL"))
|
||||
return s1.alter(field).setNotNull();
|
||||
else if (parseKeywordIf(ctx, "TO") || parseKeywordIf(ctx, "RENAME TO"))
|
||||
else if (parseKeywordIf(ctx, "TO") || parseKeywordIf(ctx, "RENAME TO") || parseKeywordIf(ctx, "RENAME AS"))
|
||||
return s1.renameColumn(field).to(parseFieldName(ctx));
|
||||
else if (parseKeywordIf(ctx, "TYPE") || parseKeywordIf(ctx, "SET DATA TYPE"))
|
||||
;
|
||||
@ -3032,7 +3041,8 @@ final class ParserImpl implements Parser {
|
||||
case 'C':
|
||||
if (parseKeywordIf(ctx, "COLUMN")) {
|
||||
TableField<?, ?> oldName = parseFieldName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Field<?> newName = parseFieldName(ctx);
|
||||
|
||||
return ctx.dsl.alterTable(oldName.getTable()).renameColumn(oldName).to(newName);
|
||||
@ -3044,7 +3054,8 @@ final class ParserImpl implements Parser {
|
||||
case 'I':
|
||||
if (parseKeywordIf(ctx, "INDEX")) {
|
||||
Name oldName = parseIndexName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Name newName = parseIndexName(ctx);
|
||||
|
||||
return ctx.dsl.alterIndex(oldName).renameTo(newName);
|
||||
@ -3056,14 +3067,16 @@ final class ParserImpl implements Parser {
|
||||
case 'S':
|
||||
if (parseKeywordIf(ctx, "SCHEMA")) {
|
||||
Schema oldName = parseSchemaName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Schema newName = parseSchemaName(ctx);
|
||||
|
||||
return ctx.dsl.alterSchema(oldName).renameTo(newName);
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "SEQUENCE")) {
|
||||
Sequence<?> oldName = parseSequenceName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Sequence<?> newName = parseSequenceName(ctx);
|
||||
|
||||
return ctx.dsl.alterSequence(oldName).renameTo(newName);
|
||||
@ -3075,7 +3088,8 @@ final class ParserImpl implements Parser {
|
||||
case 'V':
|
||||
if (parseKeywordIf(ctx, "VIEW")) {
|
||||
Table<?> oldName = parseTableName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Table<?> newName = parseTableName(ctx);
|
||||
|
||||
return ctx.dsl.alterView(oldName).renameTo(newName);
|
||||
@ -3087,7 +3101,8 @@ final class ParserImpl implements Parser {
|
||||
// If all of the above fails, we can assume we're renaming a table.
|
||||
parseKeywordIf(ctx, "TABLE");
|
||||
Table<?> oldName = parseTableName(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Table<?> newName = parseTableName(ctx);
|
||||
|
||||
return ctx.dsl.alterTable(oldName).renameTo(newName);
|
||||
@ -3133,7 +3148,9 @@ final class ParserImpl implements Parser {
|
||||
? ctx.dsl.alterSchemaIfExists(schemaName)
|
||||
: ctx.dsl.alterSchema(schemaName);
|
||||
|
||||
if (parseKeywordIf(ctx, "RENAME TO")) {
|
||||
if (parseKeywordIf(ctx, "RENAME")) {
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Schema newName = parseSchemaName(ctx);
|
||||
AlterSchemaFinalStep s2 = s1.renameTo(newName);
|
||||
return s2;
|
||||
@ -3236,7 +3253,8 @@ final class ParserImpl implements Parser {
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "RENAME CONSTRAINT")) {
|
||||
parseIdentifier(ctx);
|
||||
parseKeyword(ctx, "TO");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
parseIdentifier(ctx);
|
||||
return IGNORE;
|
||||
}
|
||||
@ -3258,7 +3276,9 @@ final class ParserImpl implements Parser {
|
||||
private static final DDLQuery parseAlterIndex(ParserContext ctx) {
|
||||
boolean ifExists = parseKeywordIf(ctx, "IF EXISTS");
|
||||
Name indexName = parseIndexName(ctx);
|
||||
parseKeyword(ctx, "RENAME TO");
|
||||
parseKeyword(ctx, "RENAME");
|
||||
if (!parseKeywordIf(ctx, "AS"))
|
||||
parseKeyword(ctx, "TO");
|
||||
Name newName = parseIndexName(ctx);
|
||||
|
||||
AlterIndexStep s1 = ifExists
|
||||
|
||||
@ -38,6 +38,7 @@
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.impl.DSL.function;
|
||||
import static org.jooq.impl.SQLDataType.NUMERIC;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ -72,6 +73,10 @@ final class Rand extends AbstractFunction<BigDecimal> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case DERBY:
|
||||
case POSTGRES:
|
||||
case SQLITE:
|
||||
|
||||
@ -60,6 +60,7 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.Keywords.K_NOT;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -54,6 +54,7 @@ import static org.jooq.SQLDialect.FIREBIRD;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.falseCondition;
|
||||
import static org.jooq.impl.DSL.trueCondition;
|
||||
|
||||
|
||||
@ -1635,6 +1635,8 @@ final class SelectQueryImpl<R extends Record> extends AbstractResultQuery<R> imp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -40,6 +40,7 @@ package org.jooq.impl;
|
||||
import static org.jooq.Clause.TRUNCATE;
|
||||
import static org.jooq.Clause.TRUNCATE_TRUNCATE;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.delete;
|
||||
import static org.jooq.impl.Keywords.K_CASCADE;
|
||||
import static org.jooq.impl.Keywords.K_CONTINUE_IDENTITY;
|
||||
import static org.jooq.impl.Keywords.K_IMMEDIATE;
|
||||
@ -71,9 +72,9 @@ final class TruncateImpl<R extends Record> extends AbstractQuery implements
|
||||
private static final long serialVersionUID = 8904572826501186329L;
|
||||
private static final Clause[] CLAUSES = { TRUNCATE };
|
||||
|
||||
private final Table<R> table;
|
||||
private Boolean cascade;
|
||||
private Boolean restartIdentity;
|
||||
private final Table<R> table;
|
||||
private Boolean cascade;
|
||||
private Boolean restartIdentity;
|
||||
|
||||
public TruncateImpl(Configuration configuration, Table<R> table) {
|
||||
super(configuration);
|
||||
@ -114,9 +115,10 @@ final class TruncateImpl<R extends Record> extends AbstractQuery implements
|
||||
|
||||
|
||||
|
||||
|
||||
case FIREBIRD:
|
||||
case SQLITE: {
|
||||
ctx.visit(create(ctx).delete(table));
|
||||
ctx.visit(delete(table));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -89,9 +89,8 @@ final class Val<T> extends AbstractParam<T> {
|
||||
else {
|
||||
|
||||
// [#1302] Bind value only if it was not explicitly forced to be inlined
|
||||
if (!isInline(ctx)) {
|
||||
if (!isInline(ctx))
|
||||
ctx.bindValue(value, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,12 +102,10 @@ final class Val<T> extends AbstractParam<T> {
|
||||
if (ctx.paramType() == NAMED || ctx.paramType() == NAMED_OR_INLINED) {
|
||||
int index = ctx.nextIndex();
|
||||
|
||||
if (StringUtils.isBlank(getParamName())) {
|
||||
if (StringUtils.isBlank(getParamName()))
|
||||
return ":" + index;
|
||||
}
|
||||
else {
|
||||
else
|
||||
return ":" + getParamName();
|
||||
}
|
||||
}
|
||||
else {
|
||||
return "?";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user