diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java index e15d8b2117..b056606107 100644 --- a/jOOQ/src/main/java/org/jooq/DSLContext.java +++ b/jOOQ/src/main/java/org/jooq/DSLContext.java @@ -9949,6 +9949,114 @@ public interface DSLContext extends Scope { @Support({ CUBRID, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES }) DropSequenceFinalStep dropSequenceIfExists(Sequence sequence); + /** + * The DROP TABLE statement. + * + * @see DSL#dropTable(String) + */ + @NotNull + @Support + DropTableStep dropTable(String table); + + /** + * The DROP TABLE statement. + * + * @see DSL#dropTable(Name) + */ + @NotNull + @Support + DropTableStep dropTable(Name table); + + /** + * The DROP TABLE statement. + * + * @see DSL#dropTable(Table) + */ + @NotNull + @Support + DropTableStep dropTable(Table table); + + /** + * The DROP TABLE IF EXISTS statement. + * + * @see DSL#dropTableIfExists(String) + */ + @NotNull + @Support + DropTableStep dropTableIfExists(String table); + + /** + * The DROP TABLE IF EXISTS statement. + * + * @see DSL#dropTableIfExists(Name) + */ + @NotNull + @Support + DropTableStep dropTableIfExists(Name table); + + /** + * The DROP TABLE IF EXISTS statement. + * + * @see DSL#dropTableIfExists(Table) + */ + @NotNull + @Support + DropTableStep dropTableIfExists(Table table); + + /** + * The DROP TEMPORARY TABLE statement. + * + * @see DSL#dropTemporaryTable(String) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + DropTableStep dropTemporaryTable(String table); + + /** + * The DROP TEMPORARY TABLE statement. + * + * @see DSL#dropTemporaryTable(Name) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + DropTableStep dropTemporaryTable(Name table); + + /** + * The DROP TEMPORARY TABLE statement. + * + * @see DSL#dropTemporaryTable(Table) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + DropTableStep dropTemporaryTable(Table table); + + /** + * The DROP TEMPORARY TABLE IF EXISTS statement. + * + * @see DSL#dropTemporaryTableIfExists(String) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + DropTableStep dropTemporaryTableIfExists(String table); + + /** + * The DROP TEMPORARY TABLE IF EXISTS statement. + * + * @see DSL#dropTemporaryTableIfExists(Name) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + DropTableStep dropTemporaryTableIfExists(Name table); + + /** + * The DROP TEMPORARY TABLE IF EXISTS statement. + * + * @see DSL#dropTemporaryTableIfExists(Table) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + DropTableStep dropTemporaryTableIfExists(Table table); + /** * The DROP VIEW statement. * @@ -11081,123 +11189,6 @@ public interface DSLContext extends Scope { @Support({ H2, MARIADB, POSTGRES }) AlterTableStep alterTableIfExists(Table table); - /** - * Create a new DSL DROP TABLE statement. - * - * @see DSL#dropTable(String) - */ - @NotNull - @Support - DropTableStep dropTable(String table); - - /** - * Create a new DSL DROP TABLE statement. - * - * @see DSL#dropTable(Name) - */ - @NotNull - @Support - DropTableStep dropTable(Name table); - - /** - * Create a new DSL DROP TABLE statement. - * - * @see DSL#dropTable(Table) - */ - @NotNull - @Support - DropTableStep dropTable(Table table); - - /** - * Create a new DSL DROP TABLE IF EXISTS statement. - *

- * If your database doesn't natively support IF EXISTS, this is - * emulated by catching (and ignoring) the relevant {@link SQLException}. - * - * @see DSL#dropTableIfExists(String) - */ - @NotNull - @Support - DropTableStep dropTableIfExists(String table); - - /** - * Create a new DSL DROP TABLE IF EXISTS statement. - *

- * If your database doesn't natively support IF EXISTS, this is - * emulated by catching (and ignoring) the relevant {@link SQLException}. - * - * @see DSL#dropTableIfExists(Name) - */ - @NotNull - @Support - DropTableStep dropTableIfExists(Name table); - - /** - * Create a new DSL DROP TABLE IF EXISTS statement. - *

- * If your database doesn't natively support IF EXISTS, this is - * emulated by catching (and ignoring) the relevant {@link SQLException}. - * - * @see DSL#dropTableIfExists(Table) - */ - @NotNull - @Support - DropTableStep dropTableIfExists(Table table); - - /** - * Create a new DSL DROP TEMPORARY TABLE statement. - * - * @see DSL#dropTemporaryTable(String) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - DropTableStep dropTemporaryTable(String table); - - /** - * Create a new DSL DROP TEMPORARY TABLE statement. - * - * @see DSL#dropTemporaryTable(Name) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - DropTableStep dropTemporaryTable(Name table); - - /** - * Create a new DSL DROP TEMPORARY TABLE statement. - * - * @see DSL#dropTemporaryTable(Table) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - DropTableStep dropTemporaryTable(Table table); - - /** - * Create a new DSL DROP TEMPORARY TABLE IF EXISTS statement. - * - * @see DSL#dropTemporaryTableIfExists(String) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - DropTableStep dropTemporaryTableIfExists(String table); - - /** - * Create a new DSL DROP TEMPORARY TABLE IF EXISTS statement. - * - * @see DSL#dropTemporaryTableIfExists(Name) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - DropTableStep dropTemporaryTableIfExists(Name table); - - /** - * Create a new DSL DROP TEMPORARY TABLE IF EXISTS statement. - * - * @see DSL#dropTemporaryTableIfExists(Table) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - DropTableStep dropTemporaryTableIfExists(Table table); - /** * Create a new DSL truncate statement. *

diff --git a/jOOQ/src/main/java/org/jooq/DropTableFinalStep.java b/jOOQ/src/main/java/org/jooq/DropTableFinalStep.java index 30ae3ad311..4ad1fc2118 100644 --- a/jOOQ/src/main/java/org/jooq/DropTableFinalStep.java +++ b/jOOQ/src/main/java/org/jooq/DropTableFinalStep.java @@ -37,9 +37,14 @@ */ package org.jooq; +import static org.jooq.SQLDialect.*; + +import java.util.*; + +import org.jetbrains.annotations.*; /** - * The final step in the DROP TABLE DSL. + * A step in the construction of the DROP TABLE statement. *

*

Referencing XYZ*Step types directly from client code

*

@@ -58,9 +63,7 @@ package org.jooq; *

  • They're less readable
  • *
  • They might have binary incompatible changes between minor releases
  • * - * - * @author Lukas Eder */ +@SuppressWarnings({ "unused" }) public interface DropTableFinalStep extends DDLQuery { - } diff --git a/jOOQ/src/main/java/org/jooq/DropTableStep.java b/jOOQ/src/main/java/org/jooq/DropTableStep.java index 720e48e99d..f4d1cdef45 100644 --- a/jOOQ/src/main/java/org/jooq/DropTableStep.java +++ b/jOOQ/src/main/java/org/jooq/DropTableStep.java @@ -37,13 +37,14 @@ */ package org.jooq; +import static org.jooq.SQLDialect.*; + +import java.util.*; + import org.jetbrains.annotations.*; - - /** - * The step in the DROP TABLE DSL used to specify DROP - * behaviour. + * A step in the construction of the DROP TABLE statement. *

    *

    Referencing XYZ*Step types directly from client code

    *

    @@ -62,24 +63,21 @@ import org.jetbrains.annotations.*; *

  • They're less readable
  • *
  • They might have binary incompatible changes between minor releases
  • * - * - * @author Lukas Eder */ +@SuppressWarnings({ "unused" }) public interface DropTableStep extends DropTableFinalStep { /** - * Add a CASCADE clause to the DROP TABLE - * statement. + * Add the CASCADE clause to the DROP TABLE statement. */ - @NotNull @Support + @NotNull DropTableFinalStep cascade(); /** - * Add a RESTRICT clause to the DROP TABLE - * statement. + * Add the RESTRICT clause to the DROP TABLE statement. */ - @NotNull @Support + @NotNull DropTableFinalStep restrict(); } diff --git a/jOOQ/src/main/java/org/jooq/impl/Cascade.java b/jOOQ/src/main/java/org/jooq/impl/Cascade.java index c961668a33..fdfd0cc68b 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Cascade.java +++ b/jOOQ/src/main/java/org/jooq/impl/Cascade.java @@ -42,5 +42,15 @@ package org.jooq.impl; * @author Lukas Eder */ enum Cascade { - CASCADE, RESTRICT + CASCADE, + RESTRICT; + + static Cascade of(Boolean b) { + if (b == null) + return null; + else if (b) + return CASCADE; + else + return RESTRICT; + } } diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 3d6ad3da36..5795f3668a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -7997,6 +7997,138 @@ public class DSL { return dsl().dropSequenceIfExists(sequence); } + /** + * The DROP TABLE statement. + * + * @see DSLContext#dropTable(String) + */ + @NotNull + @Support + public static org.jooq.DropTableStep dropTable(String table) { + return dsl().dropTable(table); + } + + /** + * The DROP TABLE statement. + * + * @see DSLContext#dropTable(Name) + */ + @NotNull + @Support + public static org.jooq.DropTableStep dropTable(Name table) { + return dsl().dropTable(table); + } + + /** + * The DROP TABLE statement. + * + * @see DSLContext#dropTable(Table) + */ + @NotNull + @Support + public static org.jooq.DropTableStep dropTable(Table table) { + return dsl().dropTable(table); + } + + /** + * The DROP TABLE IF EXISTS statement. + * + * @see DSLContext#dropTableIfExists(String) + */ + @NotNull + @Support + public static org.jooq.DropTableStep dropTableIfExists(String table) { + return dsl().dropTableIfExists(table); + } + + /** + * The DROP TABLE IF EXISTS statement. + * + * @see DSLContext#dropTableIfExists(Name) + */ + @NotNull + @Support + public static org.jooq.DropTableStep dropTableIfExists(Name table) { + return dsl().dropTableIfExists(table); + } + + /** + * The DROP TABLE IF EXISTS statement. + * + * @see DSLContext#dropTableIfExists(Table) + */ + @NotNull + @Support + public static org.jooq.DropTableStep dropTableIfExists(Table table) { + return dsl().dropTableIfExists(table); + } + + /** + * The DROP TEMPORARY TABLE statement. + * + * @see DSLContext#dropTemporaryTable(String) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + public static org.jooq.DropTableStep dropTemporaryTable(String table) { + return dsl().dropTemporaryTable(table); + } + + /** + * The DROP TEMPORARY TABLE statement. + * + * @see DSLContext#dropTemporaryTable(Name) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + public static org.jooq.DropTableStep dropTemporaryTable(Name table) { + return dsl().dropTemporaryTable(table); + } + + /** + * The DROP TEMPORARY TABLE statement. + * + * @see DSLContext#dropTemporaryTable(Table) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + public static org.jooq.DropTableStep dropTemporaryTable(Table table) { + return dsl().dropTemporaryTable(table); + } + + /** + * The DROP TEMPORARY TABLE IF EXISTS statement. + * + * @see DSLContext#dropTemporaryTableIfExists(String) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + public static org.jooq.DropTableStep dropTemporaryTableIfExists(String table) { + return dsl().dropTemporaryTableIfExists(table); + } + + /** + * The DROP TEMPORARY TABLE IF EXISTS statement. + * + * @see DSLContext#dropTemporaryTableIfExists(Name) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + public static org.jooq.DropTableStep dropTemporaryTableIfExists(Name table) { + return dsl().dropTemporaryTableIfExists(table); + } + + /** + * The DROP TEMPORARY TABLE IF EXISTS statement. + * + * @see DSLContext#dropTemporaryTableIfExists(Table) + */ + @NotNull + @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) + public static org.jooq.DropTableStep dropTemporaryTableIfExists(Table table) { + return dsl().dropTemporaryTableIfExists(table); + } + /** * The DROP VIEW statement. * @@ -9148,147 +9280,6 @@ public class DSL { return dsl().alterTableIfExists(table); } - /** - * Create a new DSL DROP TABLE statement. - * - * @see DSLContext#dropTable(String) - */ - @NotNull - @Support - public static DropTableStep dropTable(String table) { - return dsl().dropTable(table); - } - - /** - * Create a new DSL DROP TABLE statement. - * - * @see DSLContext#dropTable(Name) - */ - @NotNull - @Support - public static DropTableStep dropTable(Name table) { - return dsl().dropTable(table); - } - - /** - * Create a new DSL DROP TABLE statement. - * - * @see DSLContext#dropTable(Table) - */ - @NotNull - @Support - public static DropTableStep dropTable(Table table) { - return dsl().dropTable(table); - } - - /** - * Create a new DSL DROP TEMPORARY TABLE statement. - * - * @see DSLContext#dropTemporaryTable(String) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - public static DropTableStep dropTemporaryTable(String table) { - return dsl().dropTemporaryTable(table); - } - - /** - * Create a new DSL DROP TEMPORARY TABLE statement. - * - * @see DSLContext#dropTemporaryTable(Name) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - public static DropTableStep dropTemporaryTable(Name table) { - return dsl().dropTemporaryTable(table); - } - - /** - * Create a new DSL DROP TEMPORARY TABLE statement. - * - * @see DSLContext#dropTemporaryTable(Table) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - public static DropTableStep dropTemporaryTable(Table table) { - return dsl().dropTemporaryTable(table); - } - - /** - * Create a new DSL DROP TEMPORARY TABLE IF EXISTS statement. - * - * @see DSLContext#dropTemporaryTableIfExists(String) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - public static DropTableStep dropTemporaryTableIfExists(String table) { - return dsl().dropTemporaryTableIfExists(table); - } - - /** - * Create a new DSL DROP TEMPORARY TABLE IF EXISTS statement. - * - * @see DSLContext#dropTemporaryTableIfExists(Name) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - public static DropTableStep dropTemporaryTableIfExists(Name table) { - return dsl().dropTemporaryTableIfExists(table); - } - - /** - * Create a new DSL DROP TEMPORARY TABLE IF EXISTS statement. - * - * @see DSLContext#dropTemporaryTableIfExists(Table) - */ - @NotNull - @Support({ FIREBIRD, MARIADB, MYSQL, POSTGRES }) - public static DropTableStep dropTemporaryTableIfExists(Table table) { - return dsl().dropTemporaryTableIfExists(table); - } - - /** - * Create a new DSL DROP TABLE IF EXISTS statement. - *

    - * If your database doesn't natively support IF EXISTS, this is - * emulated by catching (and ignoring) the relevant {@link SQLException}. - * - * @see DSLContext#dropTableIfExists(String) - */ - @NotNull - @Support - public static DropTableStep dropTableIfExists(String table) { - return dsl().dropTableIfExists(table); - } - - /** - * Create a new DSL DROP TABLE IF EXISTS statement. - *

    - * If your database doesn't natively support IF EXISTS, this is - * emulated by catching (and ignoring) the relevant {@link SQLException}. - * - * @see DSLContext#dropTableIfExists(Name) - */ - @NotNull - @Support - public static DropTableStep dropTableIfExists(Name table) { - return dsl().dropTableIfExists(table); - } - - /** - * Create a new DSL DROP TABLE IF EXISTS statement. - *

    - * If your database doesn't natively support IF EXISTS, this is - * emulated by catching (and ignoring) the relevant {@link SQLException}. - * - * @see DSLContext#dropTableIfExists(Table) - */ - @NotNull - @Support - public static DropTableStep dropTableIfExists(Table table) { - return dsl().dropTableIfExists(table); - } - /** * Create a new DSL truncate statement. *

    diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java index a1e0b58d24..398aa9d91e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java @@ -3146,6 +3146,66 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri return new DropSequenceImpl(configuration(), sequence, true); } + @Override + public org.jooq.DropTableStep dropTable(String table) { + return new DropTableImpl(configuration(), false, DSL.table(DSL.name(table)), false); + } + + @Override + public org.jooq.DropTableStep dropTable(Name table) { + return new DropTableImpl(configuration(), false, DSL.table(table), false); + } + + @Override + public org.jooq.DropTableStep dropTable(Table table) { + return new DropTableImpl(configuration(), false, table, false); + } + + @Override + public org.jooq.DropTableStep dropTableIfExists(String table) { + return new DropTableImpl(configuration(), false, DSL.table(DSL.name(table)), true); + } + + @Override + public org.jooq.DropTableStep dropTableIfExists(Name table) { + return new DropTableImpl(configuration(), false, DSL.table(table), true); + } + + @Override + public org.jooq.DropTableStep dropTableIfExists(Table table) { + return new DropTableImpl(configuration(), false, table, true); + } + + @Override + public org.jooq.DropTableStep dropTemporaryTable(String table) { + return new DropTableImpl(configuration(), true, DSL.table(DSL.name(table)), false); + } + + @Override + public org.jooq.DropTableStep dropTemporaryTable(Name table) { + return new DropTableImpl(configuration(), true, DSL.table(table), false); + } + + @Override + public org.jooq.DropTableStep dropTemporaryTable(Table table) { + return new DropTableImpl(configuration(), true, table, false); + } + + @Override + public org.jooq.DropTableStep dropTemporaryTableIfExists(String table) { + return new DropTableImpl(configuration(), true, DSL.table(DSL.name(table)), true); + } + + @Override + public org.jooq.DropTableStep dropTemporaryTableIfExists(Name table) { + return new DropTableImpl(configuration(), true, DSL.table(table), true); + } + + @Override + public org.jooq.DropTableStep dropTemporaryTableIfExists(Table table) { + return new DropTableImpl(configuration(), true, table, true); + } + @Override public org.jooq.DropViewFinalStep dropView(String view) { return new DropViewImpl(configuration(), DSL.table(DSL.name(view)), false); @@ -3747,66 +3807,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri return new AlterTableImpl(configuration(), table, true); } - @Override - public DropTableStep dropTable(String table) { - return dropTable(name(table)); - } - - @Override - public DropTableStep dropTable(Name table) { - return dropTable(table(table)); - } - - @Override - public DropTableStep dropTable(Table table) { - return new DropTableImpl(configuration(), table); - } - - @Override - public DropTableStep dropTemporaryTable(String table) { - return dropTemporaryTable(name(table)); - } - - @Override - public DropTableStep dropTemporaryTable(Name table) { - return dropTemporaryTable(table(table)); - } - - @Override - public DropTableStep dropTemporaryTable(Table table) { - return new DropTableImpl(configuration(), table, false, true); - } - - @Override - public DropTableStep dropTemporaryTableIfExists(String table) { - return dropTemporaryTableIfExists(name(table)); - } - - @Override - public DropTableStep dropTemporaryTableIfExists(Name table) { - return dropTemporaryTableIfExists(table(table)); - } - - @Override - public DropTableStep dropTemporaryTableIfExists(Table table) { - return new DropTableImpl(configuration(), table, true, true); - } - - @Override - public DropTableStep dropTableIfExists(String table) { - return dropTableIfExists(name(table)); - } - - @Override - public DropTableStep dropTableIfExists(Name table) { - return dropTableIfExists(table(table)); - } - - @Override - public DropTableStep dropTableIfExists(Table table) { - return new DropTableImpl(configuration(), table, true); - } - @Override public final TruncateIdentityStep truncate(String table) { return truncateTable(table); diff --git a/jOOQ/src/main/java/org/jooq/impl/DropTableImpl.java b/jOOQ/src/main/java/org/jooq/impl/DropTableImpl.java index 2ceeac0bc2..cc9f1fdf23 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DropTableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/DropTableImpl.java @@ -37,100 +37,101 @@ */ package org.jooq.impl; -import static org.jooq.Clause.DROP_TABLE; -import static org.jooq.Clause.DROP_TABLE_TABLE; -// ... -// ... -// ... -// ... -import static org.jooq.SQLDialect.DERBY; -import static org.jooq.SQLDialect.FIREBIRD; -// ... -import static org.jooq.SQLDialect.MYSQL; -// ... -// ... -// ... -import static org.jooq.impl.Cascade.CASCADE; -import static org.jooq.impl.Cascade.RESTRICT; -import static org.jooq.impl.Keywords.K_CASCADE; -import static org.jooq.impl.Keywords.K_DROP; -import static org.jooq.impl.Keywords.K_DROP_TABLE; -import static org.jooq.impl.Keywords.K_IF_EXISTS; -import static org.jooq.impl.Keywords.K_RESTRICT; -import static org.jooq.impl.Keywords.K_TABLE; -import static org.jooq.impl.Keywords.K_TEMPORARY; +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.SQLDialect.*; -import java.util.Set; +import org.jooq.*; +import org.jooq.impl.*; +import org.jooq.tools.*; -import org.jooq.Clause; -import org.jooq.Configuration; -import org.jooq.Context; -import org.jooq.DropTableStep; -import org.jooq.SQLDialect; -import org.jooq.Table; +import java.util.*; /** - * @author Lukas Eder + * The DROP TABLE statement. */ -final class DropTableImpl extends AbstractRowCountQuery implements +@SuppressWarnings({ "rawtypes", "unused" }) +final class DropTableImpl +extends + AbstractRowCountQuery +implements + DropTableStep, + DropTableFinalStep +{ - // Cascading interface implementations for DROP TABLE behaviour - DropTableStep { + private static final long serialVersionUID = 1L; - /** - * Generated UID - */ - private static final long serialVersionUID = 8904572826501186329L; - private static final Clause[] CLAUSES = { DROP_TABLE }; - private static final Set NO_SUPPORT_IF_EXISTS = SQLDialect.supportedBy(DERBY, FIREBIRD); - private static final Set TEMPORARY_SEMANTIC = SQLDialect.supportedBy(MYSQL); + private final Boolean temporary; + private final Table table; + private final boolean dropTableIfExists; + private Boolean cascade; - private final Table table; - private final boolean temporary; - private final boolean ifExists; - private Cascade cascade; - - DropTableImpl(Configuration configuration, Table table) { - this(configuration, table, false, false); + DropTableImpl( + Configuration configuration, + Boolean temporary, + Table table, + boolean dropTableIfExists + ) { + this( + configuration, + temporary, + table, + dropTableIfExists, + null + ); } - DropTableImpl(Configuration configuration, Table table, boolean ifExists) { - this(configuration, table, ifExists, false); - } - - DropTableImpl(Configuration configuration, Table table, boolean ifExists, boolean temporary) { + DropTableImpl( + Configuration configuration, + Boolean temporary, + Table table, + boolean dropTableIfExists, + Boolean cascade + ) { super(configuration); - this.table = table; - this.ifExists = ifExists; this.temporary = temporary; + this.table = table; + this.dropTableIfExists = dropTableIfExists; + this.cascade = cascade; } - final Table $table() { return table; } - final boolean $temporary() { return temporary; } - final boolean $ifExists() { return ifExists; } - final Cascade $cascade() { return cascade; } + final Boolean $temporary() { return temporary; } + final Table $table() { return table; } + final boolean $dropTableIfExists() { return dropTableIfExists; } + final Boolean $cascade() { return cascade; } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- // XXX: DSL API - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- @Override public final DropTableImpl cascade() { - cascade = CASCADE; + this.cascade = true; return this; } @Override public final DropTableImpl restrict() { - cascade = RESTRICT; + this.cascade = false; return this; } - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- // XXX: QueryPart API - // ------------------------------------------------------------------------ + // ------------------------------------------------------------------------- + + + + private static final Clause[] CLAUSES = { Clause.DROP_TABLE }; + private static final Set NO_SUPPORT_IF_EXISTS = SQLDialect.supportedBy(DERBY, FIREBIRD); + private static final Set TEMPORARY_SEMANTIC = SQLDialect.supportedBy(MYSQL); private final boolean supportsIfExists(Context ctx) { return !NO_SUPPORT_IF_EXISTS.contains(ctx.dialect()); @@ -138,18 +139,17 @@ final class DropTableImpl extends AbstractRowCountQuery implements @Override public final void accept(Context ctx) { - if (ifExists && !supportsIfExists(ctx)) { + if (dropTableIfExists && !supportsIfExists(ctx)) { Tools.beginTryCatch(ctx, DDLStatementType.DROP_TABLE); accept0(ctx); Tools.endTryCatch(ctx, DDLStatementType.DROP_TABLE); } - else { + else accept0(ctx); - } } private void accept0(Context ctx) { - ctx.start(DROP_TABLE_TABLE); + ctx.start(Clause.DROP_TABLE_TABLE); // [#6371] [#9019] While many dialects do not require this keyword, in // some dialects (e.g. MySQL), there is a semantic @@ -160,17 +160,17 @@ final class DropTableImpl extends AbstractRowCountQuery implements ctx.visit(K_DROP_TABLE).sql(' '); - if (ifExists && supportsIfExists(ctx)) + if (dropTableIfExists && supportsIfExists(ctx)) ctx.visit(K_IF_EXISTS).sql(' '); ctx.visit(table); - if (cascade == CASCADE) + if (Boolean.TRUE.equals(cascade)) ctx.sql(' ').visit(K_CASCADE); - else if (cascade == RESTRICT) + else if (Boolean.FALSE.equals(cascade)) ctx.sql(' ').visit(K_RESTRICT); - ctx.end(DROP_TABLE_TABLE); + ctx.end(Clause.DROP_TABLE_TABLE); } @@ -178,4 +178,6 @@ final class DropTableImpl extends AbstractRowCountQuery implements public final Clause[] clauses(Context ctx) { return CLAUSES; } + + } diff --git a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java index 5e9acbf887..26af40a669 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java +++ b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java @@ -759,7 +759,7 @@ final class Interpreter { MutableSchema schema = getSchema(table.getSchema()); MutableTable existing = schema.table(table); if (existing == null) { - if (!query.$ifExists()) + if (!query.$dropTableIfExists()) throw notExists(table); return; @@ -769,7 +769,7 @@ final class Interpreter { else if (query.$temporary() && existing.options.type() != TableType.TEMPORARY) throw objectNotTemporaryTable(table); - drop(schema.tables, existing, query.$cascade()); + drop(schema.tables, existing, Cascade.of(query.$cascade())); } private final void accept0(TruncateImpl query) {