[#9382] Add support for Oracle's ALTER TABLE .. DROP UNIQUE (<columns>) syntax
This commit is contained in:
parent
a78679b0fa
commit
41263129d2
@ -1592,7 +1592,10 @@ final class AlterTableImpl extends AbstractRowCountQuery implements
|
||||
ctx.visit(K_DROP).sql(' ').visit(K_PRIMARY_KEY);
|
||||
}
|
||||
else {
|
||||
ctx.visit(K_DROP_CONSTRAINT).sql(' ');
|
||||
|
||||
// [#9382] In some dialects, unnamed UNIQUE constraints can be
|
||||
// dropped by dropping their declarations.
|
||||
ctx.visit(dropConstraint.getUnqualifiedName().empty() ? K_DROP : K_DROP_CONSTRAINT).sql(' ');
|
||||
|
||||
if (ifExistsConstraint)
|
||||
ctx.visit(K_IF_EXISTS).sql(' ');
|
||||
|
||||
@ -99,7 +99,6 @@ import org.jooq.Name;
|
||||
// ...
|
||||
import org.jooq.SQLDialect;
|
||||
import org.jooq.Table;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
@ -188,16 +187,15 @@ implements
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (TRUE.equals(ctx.data(DATA_CONSTRAINT_REFERENCE))) {
|
||||
if (getQualifiedName().equals(AbstractName.NO_NAME))
|
||||
throw new DataAccessException("Cannot ALTER or DROP CONSTRAINT without name");
|
||||
boolean named = !getQualifiedName().equals(AbstractName.NO_NAME);
|
||||
|
||||
if (named && TRUE.equals(ctx.data(DATA_CONSTRAINT_REFERENCE))) {
|
||||
ctx.visit(getQualifiedName());
|
||||
}
|
||||
else {
|
||||
boolean qualify = ctx.qualify();
|
||||
|
||||
if (!getQualifiedName().equals(AbstractName.NO_NAME)) {
|
||||
if (named) {
|
||||
ctx.visit(K_CONSTRAINT)
|
||||
.sql(' ')
|
||||
.visit(getUnqualifiedName())
|
||||
@ -279,7 +277,7 @@ implements
|
||||
.sql(')');
|
||||
}
|
||||
|
||||
if (!getQualifiedName().equals(AbstractName.NO_NAME)) {
|
||||
if (named) {
|
||||
|
||||
|
||||
|
||||
|
||||
@ -3898,7 +3898,10 @@ final class ParserImpl implements Parser {
|
||||
: s1.dropConstraint(parseIdentifier(ctx)));
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "UNIQUE")) {
|
||||
return parseCascadeRestrictIf(ctx, s1.dropUnique(parseIdentifier(ctx)));
|
||||
return parseCascadeRestrictIf(ctx, s1.dropUnique(
|
||||
peek(ctx, '(')
|
||||
? unique(parseKeyColumnList(ctx))
|
||||
: constraint(parseIdentifier(ctx))));
|
||||
}
|
||||
else if (parseKeywordIf(ctx, "PRIMARY KEY")) {
|
||||
Name identifier = parseIdentifierIf(ctx);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user