[#6121] Add support for DB2 RENAME TABLE statement

This commit is contained in:
lukaseder 2017-04-21 13:30:41 +02:00
parent c8e851b52f
commit 2d588af128
2 changed files with 7 additions and 5 deletions

View File

@ -76,6 +76,7 @@ import static org.jooq.impl.Keywords.K_NOT_NULL;
import static org.jooq.impl.Keywords.K_NULL;
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_TABLE;
import static org.jooq.impl.Keywords.K_RENAME_TO;
import static org.jooq.impl.Keywords.K_SET_DATA_TYPE;
import static org.jooq.impl.Keywords.K_SET_DEFAULT;
@ -448,12 +449,12 @@ final class AlterTableImpl extends AbstractQuery implements
private final void accept1(Context<?> ctx) {
SQLDialect family = ctx.family();
boolean omitAlterTable =
family == HSQLDB && renameConstraint != null;
boolean omitAlterTable = family == HSQLDB && renameConstraint != null;
boolean renameTable = asList().contains(family);
if (!omitAlterTable) {
ctx.start(ALTER_TABLE_TABLE)
.visit(K_ALTER_TABLE);
.visit(renameTable ? K_RENAME_TABLE : K_ALTER_TABLE);
if (ifExists && supportsIfExists(ctx))
ctx.sql(' ').visit(K_IF_EXISTS);
@ -469,7 +470,7 @@ final class AlterTableImpl extends AbstractQuery implements
ctx.start(ALTER_TABLE_RENAME)
.qualify(false)
.visit(K_RENAME_TO).sql(' ')
.visit(renameTable ? K_TO : K_RENAME_TO).sql(' ')
.visit(renameTo)
.qualify(qualify)
.end(ALTER_TABLE_RENAME);

View File

@ -195,9 +195,10 @@ final class Keywords {
public static final Keyword K_REFERENCES = keyword("references");
public static final Keyword K_REGEXP = keyword("regexp");
public static final Keyword K_RENAME = keyword("rename");
public static final Keyword K_RENAME_INDEX = keyword("rename index");
public static final Keyword K_RENAME_COLUMN = keyword("rename column");
public static final Keyword K_RENAME_CONSTRAINT = keyword("rename constraint");
public static final Keyword K_RENAME_INDEX = keyword("rename index");
public static final Keyword K_RENAME_TABLE = keyword("rename table");
public static final Keyword K_RENAME_TO = keyword("rename to");
public static final Keyword K_RESPECT_NULLS = keyword("respect nulls");
public static final Keyword K_RESTART = keyword("restart");