From ffb4ad44a98b3d2794bbd9f7c763fd816fad4f74 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Thu, 12 Dec 2019 09:15:04 +0100 Subject: [PATCH] [jOOQ/jOOQ#7511] Fix DDLInterpreter and AlterTableImpl in OSS edition --- jOOQ/pom.xml | 2 ++ .../java/org/jooq/impl/AlterTableImpl.java | 4 +++- .../java/org/jooq/impl/DDLInterpreter.java | 20 +++++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/jOOQ/pom.xml b/jOOQ/pom.xml index 1f2a4d2587..df642e94e5 100644 --- a/jOOQ/pom.xml +++ b/jOOQ/pom.xml @@ -148,6 +148,8 @@ + + diff --git a/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java b/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java index 5468aa926f..1fd0bbae61 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java @@ -204,7 +204,9 @@ final class AlterTableImpl extends AbstractRowCountQuery implements AlterTableAddStep, AlterTableDropStep, AlterTableAlterStep, - AlterTableAlterConstraintStep, + + + AlterTableUsingIndexStep, AlterTableRenameColumnToStep, AlterTableRenameIndexToStep, diff --git a/jOOQ/src/main/java/org/jooq/impl/DDLInterpreter.java b/jOOQ/src/main/java/org/jooq/impl/DDLInterpreter.java index 6c44ca427d..03e338ceb7 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DDLInterpreter.java +++ b/jOOQ/src/main/java/org/jooq/impl/DDLInterpreter.java @@ -321,8 +321,9 @@ final class DDLInterpreter { if (mu == null) throw primaryKeyNotExists(); + boolean enforced = true; mt.foreignKeys.add(new MutableForeignKey( - (UnqualifiedName) impl.getUnqualifiedName(), mt, mfs, mu, impl.$onDelete(), impl.$onUpdate(), impl.$enforced() + (UnqualifiedName) impl.getUnqualifiedName(), mt, mfs, mu, impl.$onDelete(), impl.$onUpdate(), enforced )); } @@ -529,9 +530,11 @@ final class DDLInterpreter { else mc.name((UnqualifiedName) query.$renameConstraintTo().getUnqualifiedName()); } - else if (query.$alterConstraint() != null) { - existing.constraint(query.$alterConstraint(), true).enforced = query.$alterConstraintEnforced(); - } + + + + + else if (query.$dropColumns() != null) { List fields = existing.fields(query.$dropColumns().toArray(EMPTY_FIELD), false); @@ -668,17 +671,18 @@ final class DDLInterpreter { private final void addConstraint(Query query, ConstraintImpl impl, MutableTable existing) { if (!impl.getUnqualifiedName().empty() && existing.constraint(impl) != null) throw constraintAlreadyExists(impl); - else if (impl.$primaryKey() != null) + boolean enforced = true; + if (impl.$primaryKey() != null) if (existing.primaryKey != null) throw constraintAlreadyExists(impl); else - existing.primaryKey = new MutableUniqueKey((UnqualifiedName) impl.getUnqualifiedName(), existing, existing.fields(impl.$primaryKey(), true), impl.$enforced()); + existing.primaryKey = new MutableUniqueKey((UnqualifiedName) impl.getUnqualifiedName(), existing, existing.fields(impl.$primaryKey(), true), enforced); else if (impl.$unique() != null) - existing.uniqueKeys.add(new MutableUniqueKey((UnqualifiedName) impl.getUnqualifiedName(), existing, existing.fields(impl.$unique(), true), impl.$enforced())); + existing.uniqueKeys.add(new MutableUniqueKey((UnqualifiedName) impl.getUnqualifiedName(), existing, existing.fields(impl.$unique(), true), enforced)); else if (impl.$foreignKey() != null) addForeignKey(getSchema(impl.$referencesTable().getSchema(), false), existing, impl); else if (impl.$check() != null) - existing.checks.add(new MutableCheck((UnqualifiedName) impl.getUnqualifiedName(), existing, impl.$check(), impl.$enforced())); + existing.checks.add(new MutableCheck((UnqualifiedName) impl.getUnqualifiedName(), existing, impl.$check(), enforced)); else throw unsupportedQuery(query); }