table);
-
- /**
- * Create a new DSL truncate statement.
- *
- * Example:
- *
- *
- * DSLContext create = DSL.using(configuration);
- *
- * create.truncate(table)
- * .execute();
- *
- *
Emulation of TRUNCATE
- *
- * Most dialects implement the TRUNCATE statement. If it is not
- * supported, it is emulated using an equivalent DELETE
- * statement. This is particularly true for these dialects:
- *
- * - {@link SQLDialect#FIREBIRD}
- * - {@link SQLDialect#INGRES}
- * - {@link SQLDialect#SQLITE}
- *
- * Vendor-specific extensions of TRUNCATE
- *
- * Some statements also support extensions of the TRUNCATE
- * statement, such as Postgres:
- *
- *
- * create.truncate(table)
- * .restartIdentity()
- * .cascade()
- * .execute();
- *
- *
- * These vendor-specific extensions are currently not emulated for those
- * dialects that do not support them natively.
- *
- * @see #truncate(Table)
- */
- @NotNull
- @Support
- TruncateIdentityStep truncateTable(String table);
-
- /**
- * Create a new DSL truncate statement.
- *
- * Example:
- *
- *
- * DSLContext create = DSL.using(configuration);
- *
- * create.truncate(table)
- * .execute();
- *
- *
Emulation of TRUNCATE
- *
- * Most dialects implement the TRUNCATE statement. If it is not
- * supported, it is emulated using an equivalent DELETE
- * statement. This is particularly true for these dialects:
- *
- * - {@link SQLDialect#FIREBIRD}
- * - {@link SQLDialect#INGRES}
- * - {@link SQLDialect#SQLITE}
- *
- * Vendor-specific extensions of TRUNCATE
- *
- * Some statements also support extensions of the TRUNCATE
- * statement, such as Postgres:
- *
- *
- * create.truncate(table)
- * .restartIdentity()
- * .cascade()
- * .execute();
- *
- *
- * These vendor-specific extensions are currently not emulated for those
- * dialects that do not support them natively.
- *
- * @see #truncate(Name)
- */
- @NotNull
- @Support
- TruncateIdentityStep truncateTable(Name table);
-
- /**
- * Create a new DSL truncate statement.
- *
- * Example:
- *
- *
- * DSLContext create = DSL.using(configuration);
- *
- * create.truncate(table)
- * .execute();
- *
- *
Emulation of TRUNCATE
- *
- * Most dialects implement the TRUNCATE statement. If it is not
- * supported, it is emulated using an equivalent DELETE
- * statement. This is particularly true for these dialects:
- *
- * - {@link SQLDialect#FIREBIRD}
- * - {@link SQLDialect#INGRES}
- * - {@link SQLDialect#SQLITE}
- *
- * Vendor-specific extensions of TRUNCATE
- *
- * Some statements also support extensions of the TRUNCATE
- * statement, such as Postgres:
- *
- *
- * create.truncate(table)
- * .restartIdentity()
- * .cascade()
- * .execute();
- *
- *
- * These vendor-specific extensions are currently not emulated for those
- * dialects that do not support them natively.
- */
- @NotNull
- @Support
- TruncateIdentityStep truncateTable(Table table);
-
// -------------------------------------------------------------------------
// XXX Other queries for identites and sequences
// -------------------------------------------------------------------------
diff --git a/jOOQ/src/main/java/org/jooq/Truncate.java b/jOOQ/src/main/java/org/jooq/Truncate.java
index 05b7755e86..abcc753244 100644
--- a/jOOQ/src/main/java/org/jooq/Truncate.java
+++ b/jOOQ/src/main/java/org/jooq/Truncate.java
@@ -37,24 +37,33 @@
*/
package org.jooq;
-import org.jooq.impl.DSL;
+import static org.jooq.SQLDialect.*;
+
+import java.util.*;
+
+import org.jetbrains.annotations.*;
/**
- * A TRUNCATE statement.
+ * A step in the construction of the TRUNCATE statement.
*
- * Example:
+ *
Referencing XYZ*Step types directly from client code
*
- *
- * // Assuming import static org.jooq.impl.DSL.*;
- *
- * using(configuration).truncate(ACTOR).execute();
- *
+ * It is usually not recommended to reference any XYZ*Step types
+ * directly from client code, or assign them to local variables. When writing
+ * dynamic SQL, creating a statement's components dynamically, and passing them
+ * to the DSL API statically is usually a better choice. See the manual's
+ * section about dynamic SQL for details: https://www.jooq.org/doc/latest/manual/sql-building/dynamic-sql.
*
- * Instances can be created using {@link DSL#truncate(Table)}, or
- * {@link DSLContext#truncate(Table)} and overloads.
- *
- * @author Lukas Eder
+ * Drawbacks of referencing the XYZ*Step types directly:
+ *
+ * - They're operating on mutable implementations (as of jOOQ 3.x)
+ * - They're less composable and not easy to get right when dynamic SQL gets
+ * complex
+ * - They're less readable
+ * - They might have binary incompatible changes between minor releases
+ *
*/
+@SuppressWarnings({ "unused" })
public interface Truncate extends DDLQuery {
-
}
diff --git a/jOOQ/src/main/java/org/jooq/TruncateCascadeStep.java b/jOOQ/src/main/java/org/jooq/TruncateCascadeStep.java
index d8de1684e3..4d2625f665 100644
--- a/jOOQ/src/main/java/org/jooq/TruncateCascadeStep.java
+++ b/jOOQ/src/main/java/org/jooq/TruncateCascadeStep.java
@@ -37,16 +37,14 @@
*/
package org.jooq;
+import static org.jooq.SQLDialect.*;
+
+import java.util.*;
+
import org.jetbrains.annotations.*;
-
-// ...
-// ...
-// ...
-import static org.jooq.SQLDialect.POSTGRES;
-
/**
- * A {@link Query} that can truncate a table in the database.
+ * A step in the construction of the TRUNCATE statement.
*
*
Referencing XYZ*Step types directly from client code
*
@@ -65,24 +63,21 @@ import static org.jooq.SQLDialect.POSTGRES;
*
They're less readable
* They might have binary incompatible changes between minor releases
*
- *
- * @author Lukas Eder
*/
+@SuppressWarnings({ "unused" })
public interface TruncateCascadeStep extends TruncateFinalStep {
/**
- * Add the CASCADE clause to the TRUNCATE
- * statement.
+ * Add the CASCADE clause to the TRUNCATE statement.
*/
- @NotNull
@Support({ POSTGRES })
+ @NotNull
TruncateFinalStep cascade();
/**
- * Add the RESTRICT clause to the TRUNCATE
- * statement.
+ * Add the RESTRICT clause to the TRUNCATE statement.
*/
- @NotNull
@Support({ POSTGRES })
+ @NotNull
TruncateFinalStep restrict();
}
diff --git a/jOOQ/src/main/java/org/jooq/TruncateFinalStep.java b/jOOQ/src/main/java/org/jooq/TruncateFinalStep.java
index e543d4058c..7b6b1c312a 100644
--- a/jOOQ/src/main/java/org/jooq/TruncateFinalStep.java
+++ b/jOOQ/src/main/java/org/jooq/TruncateFinalStep.java
@@ -37,10 +37,14 @@
*/
package org.jooq;
+import static org.jooq.SQLDialect.*;
+import java.util.*;
+
+import org.jetbrains.annotations.*;
/**
- * A {@link Query} that can truncate a table in the database.
+ * A step in the construction of the TRUNCATE statement.
*
*
Referencing XYZ*Step types directly from client code
*
@@ -59,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 TruncateFinalStep extends Truncate {
-
}
diff --git a/jOOQ/src/main/java/org/jooq/TruncateIdentityStep.java b/jOOQ/src/main/java/org/jooq/TruncateIdentityStep.java
index 1bbecf755b..6392fbc9ce 100644
--- a/jOOQ/src/main/java/org/jooq/TruncateIdentityStep.java
+++ b/jOOQ/src/main/java/org/jooq/TruncateIdentityStep.java
@@ -37,15 +37,14 @@
*/
package org.jooq;
+import static org.jooq.SQLDialect.*;
+
+import java.util.*;
+
import org.jetbrains.annotations.*;
-
-// ...
-import static org.jooq.SQLDialect.HSQLDB;
-import static org.jooq.SQLDialect.POSTGRES;
-
/**
- * A {@link Query} that can truncate a table in the database.
+ * A step in the construction of the TRUNCATE statement.
*
*
Referencing XYZ*Step types directly from client code
*
@@ -64,24 +63,21 @@ import static org.jooq.SQLDialect.POSTGRES;
*
They're less readable
* They might have binary incompatible changes between minor releases
*
- *
- * @author Lukas Eder
*/
+@SuppressWarnings({ "unused" })
public interface TruncateIdentityStep extends TruncateCascadeStep {
/**
- * Add the RESTART IDENTITY clause to the TRUNCATE
- * statement.
+ * Add the RESTART IDENTITY clause to the TRUNCATE statement.
*/
- @NotNull
@Support({ HSQLDB, POSTGRES })
+ @NotNull
TruncateCascadeStep restartIdentity();
/**
- * Add the CONTINUE IDENTITY clause to the
- * TRUNCATE statement.
+ * Add the CONTINUE IDENTITY clause to the TRUNCATE statement.
*/
- @NotNull
@Support({ HSQLDB, POSTGRES })
+ @NotNull
TruncateCascadeStep continueIdentity();
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java
index c49bfa5f97..4d62800a1a 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DSL.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java
@@ -8583,6 +8583,72 @@ public class DSL {
return dsl().setSchema(schema);
}
+ /**
+ * The TRUNCATE statement.
+ *
+ * @see DSLContext#truncate(String)
+ */
+ @NotNull
+ @Support
+ public static org.jooq.TruncateIdentityStep truncate(String table) {
+ return dsl().truncate(table);
+ }
+
+ /**
+ * The TRUNCATE statement.
+ *
+ * @see DSLContext#truncate(Name)
+ */
+ @NotNull
+ @Support
+ public static org.jooq.TruncateIdentityStep truncate(Name table) {
+ return dsl().truncate(table);
+ }
+
+ /**
+ * The TRUNCATE statement.
+ *
+ * @see DSLContext#truncate(Table)
+ */
+ @NotNull
+ @Support
+ public static org.jooq.TruncateIdentityStep truncate(Table table) {
+ return dsl().truncate(table);
+ }
+
+ /**
+ * The TRUNCATE TABLE statement.
+ *
+ * @see DSLContext#truncateTable(String)
+ */
+ @NotNull
+ @Support
+ public static org.jooq.TruncateIdentityStep truncateTable(String table) {
+ return dsl().truncateTable(table);
+ }
+
+ /**
+ * The TRUNCATE TABLE statement.
+ *
+ * @see DSLContext#truncateTable(Name)
+ */
+ @NotNull
+ @Support
+ public static org.jooq.TruncateIdentityStep truncateTable(Name table) {
+ return dsl().truncateTable(table);
+ }
+
+ /**
+ * The TRUNCATE TABLE statement.
+ *
+ * @see DSLContext#truncateTable(Table)
+ */
+ @NotNull
+ @Support
+ public static org.jooq.TruncateIdentityStep truncateTable(Table table) {
+ return dsl().truncateTable(table);
+ }
+
/**
@@ -9302,183 +9368,6 @@ public class DSL {
return dsl().alterTableIfExists(table);
}
- /**
- * Create a new DSL truncate statement.
- *
- * Synonym for {@link #truncateTable(String)}
- */
- @NotNull
- @Support
- public static TruncateIdentityStep truncate(String table) {
- return truncateTable(table);
- }
-
- /**
- * Create a new DSL truncate statement.
- *
- * Synonym for {@link #truncateTable(Name)}
- */
- @NotNull
- @Support
- public static TruncateIdentityStep truncate(Name table) {
- return truncateTable(table);
- }
-
- /**
- * Create a new DSL truncate statement.
- *
- * Synonym for {@link #truncateTable(Table)}
- */
- @NotNull
- @Support
- public static TruncateIdentityStep truncate(Table table) {
- return truncateTable(table);
- }
-
- /**
- * Create a new DSL truncate statement.
- *
- * Unlike {@link Delete} factory methods in the {@link DSLContext} API, this
- * creates an unattached, and thus not directly renderable or executable
- * DELETE statement.
- *
- * Example:
- *
- *
- * import static org.jooq.impl.DSL.*;
- *
- * // [...]
- *
- * truncate(table);
- *
- *
Simulation of TRUNCATE
- *
- * Most dialects implement the TRUNCATE statement. If it is not
- * supported, it is emulated using an equivalent DELETE
- * statement. This is particularly true for these dialects:
- *
- * - {@link SQLDialect#FIREBIRD}
- * - {@link SQLDialect#INGRES}
- * - {@link SQLDialect#SQLITE}
- *
- * Vendor-specific extensions of TRUNCATE
- *
- * Some statements also support extensions of the TRUNCATE
- * statement, such as Postgres:
- *
- *
- * truncate(table)
- * .restartIdentity()
- * .cascade()
- *
- *
- * These vendor-specific extensions are currently not emulated for those
- * dialects that do not support them natively.
- *
- * @see DSLContext#truncate(String)
- */
- @NotNull
- @Support
- public static TruncateIdentityStep truncateTable(String table) {
- return dsl().truncateTable(table);
- }
-
- /**
- * Create a new DSL truncate statement.
- *
- * Unlike {@link Delete} factory methods in the {@link DSLContext} API, this
- * creates an unattached, and thus not directly renderable or executable
- * DELETE statement.
- *
- * Example:
- *
- *
- * import static org.jooq.impl.DSL.*;
- *
- * // [...]
- *
- * truncate(table);
- *
- *
Simulation of TRUNCATE
- *
- * Most dialects implement the TRUNCATE statement. If it is not
- * supported, it is emulated using an equivalent DELETE
- * statement. This is particularly true for these dialects:
- *
- * - {@link SQLDialect#FIREBIRD}
- * - {@link SQLDialect#INGRES}
- * - {@link SQLDialect#SQLITE}
- *
- * Vendor-specific extensions of TRUNCATE
- *
- * Some statements also support extensions of the TRUNCATE
- * statement, such as Postgres:
- *
- *
- * truncate(table)
- * .restartIdentity()
- * .cascade()
- *
- *
- * These vendor-specific extensions are currently not emulated for those
- * dialects that do not support them natively.
- *
- * @see DSLContext#truncate(Name)
- */
- @NotNull
- @Support
- public static TruncateIdentityStep truncateTable(Name table) {
- return dsl().truncateTable(table);
- }
-
- /**
- * Create a new DSL truncate statement.
- *
- * Unlike {@link Delete} factory methods in the {@link DSLContext} API, this
- * creates an unattached, and thus not directly renderable or executable
- * DELETE statement.
- *
- * Example:
- *
- *
- * import static org.jooq.impl.DSL.*;
- *
- * // [...]
- *
- * truncate(table);
- *
- *
Simulation of TRUNCATE
- *
- * Most dialects implement the TRUNCATE statement. If it is not
- * supported, it is emulated using an equivalent DELETE
- * statement. This is particularly true for these dialects:
- *
- * - {@link SQLDialect#FIREBIRD}
- * - {@link SQLDialect#INGRES}
- * - {@link SQLDialect#SQLITE}
- *
- * Vendor-specific extensions of TRUNCATE
- *
- * Some statements also support extensions of the TRUNCATE
- * statement, such as Postgres:
- *
- *
- * truncate(table)
- * .restartIdentity()
- * .cascade()
- *
- *
- * These vendor-specific extensions are currently not emulated for those
- * dialects that do not support them natively.
- *
- * @see DSLContext#truncate(Table)
- */
- @NotNull
- @Support
- public static TruncateIdentityStep truncateTable(Table table) {
- return dsl().truncateTable(table);
- }
-
// -------------------------------------------------------------------------
// XXX Quantified comparison predicate expressions
// -------------------------------------------------------------------------
diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java
index 967158f2eb..e96352aec2 100644
--- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java
+++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java
@@ -3406,6 +3406,36 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new SetSchema(configuration(), schema);
}
+ @Override
+ public org.jooq.TruncateIdentityStep truncate(String table) {
+ return new TruncateImpl(configuration(), DSL.table(DSL.name(table)));
+ }
+
+ @Override
+ public org.jooq.TruncateIdentityStep truncate(Name table) {
+ return new TruncateImpl(configuration(), DSL.table(table));
+ }
+
+ @Override
+ public org.jooq.TruncateIdentityStep truncate(Table table) {
+ return new TruncateImpl(configuration(), table);
+ }
+
+ @Override
+ public org.jooq.TruncateIdentityStep truncateTable(String table) {
+ return truncate(DSL.table(DSL.name(table)));
+ }
+
+ @Override
+ public org.jooq.TruncateIdentityStep truncateTable(Name table) {
+ return truncate(DSL.table(table));
+ }
+
+ @Override
+ public org.jooq.TruncateIdentityStep truncateTable(Table table) {
+ return truncate(table);
+ }
+
@Override
@@ -3817,36 +3847,6 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri
return new AlterTableImpl(configuration(), table, true);
}
- @Override
- public final TruncateIdentityStep truncate(String table) {
- return truncateTable(table);
- }
-
- @Override
- public final TruncateIdentityStep truncate(Name table) {
- return truncateTable(table);
- }
-
- @Override
- public TruncateIdentityStep truncate(Table table) {
- return truncateTable(table);
- }
-
- @Override
- public final TruncateIdentityStep truncateTable(String table) {
- return truncateTable(name(table));
- }
-
- @Override
- public final TruncateIdentityStep truncateTable(Name table) {
- return truncateTable(table(table));
- }
-
- @Override
- public TruncateIdentityStep truncateTable(Table table) {
- return new TruncateImpl<>(configuration(), table);
- }
-
// -------------------------------------------------------------------------
// XXX Other queries for identites and sequences
// -------------------------------------------------------------------------
diff --git a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java
index 2ab924f9d8..281f493abf 100644
--- a/jOOQ/src/main/java/org/jooq/impl/Interpreter.java
+++ b/jOOQ/src/main/java/org/jooq/impl/Interpreter.java
@@ -783,7 +783,7 @@ final class Interpreter {
throw notExists(table);
else if (!existing.options.type().isTable())
throw objectNotTable(table);
- else if (!query.$cascade() && existing.hasReferencingKeys())
+ else if (!TRUE.equals(query.$cascade()) && existing.hasReferencingKeys())
throw new DataDefinitionException("Cannot truncate table referenced by other tables. Use CASCADE: " + table);
}
diff --git a/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java b/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java
index 2092c7c299..283e79a0e3 100644
--- a/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java
+++ b/jOOQ/src/main/java/org/jooq/impl/SelectQueryImpl.java
@@ -68,6 +68,7 @@ import static org.jooq.Operator.OR;
import static org.jooq.SQLDialect.CUBRID;
// ...
// ...
+import static org.jooq.SQLDialect.DEFAULT;
import static org.jooq.SQLDialect.DERBY;
import static org.jooq.SQLDialect.FIREBIRD;
import static org.jooq.SQLDialect.H2;
@@ -269,7 +270,7 @@ final class SelectQueryImpl extends AbstractResultQuery imp
static final Set SUPPORT_WINDOW_CLAUSE = SQLDialect.supportedBy(H2, MYSQL, POSTGRES, SQLITE);
- private static final Set OPTIONAL_FROM_CLAUSE = SQLDialect.supportedBy(H2, MARIADB, MYSQL, POSTGRES, SQLITE);
+ private static final Set OPTIONAL_FROM_CLAUSE = SQLDialect.supportedBy(DEFAULT, H2, MARIADB, MYSQL, POSTGRES, SQLITE);
private static final Set REQUIRES_DERIVED_TABLE_DML = SQLDialect.supportedBy(MARIADB, MYSQL);
private static final Set EMULATE_EMPTY_GROUP_BY_CONSTANT = SQLDialect.supportedUntil(DERBY, HSQLDB);
private static final Set EMULATE_EMPTY_GROUP_BY_OTHER = SQLDialect.supportedUntil(FIREBIRD, MARIADB, MYSQL, SQLITE);
diff --git a/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java b/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java
index d3fd001472..de4f09ce45 100644
--- a/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java
+++ b/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java
@@ -37,86 +37,107 @@
*/
package org.jooq.impl;
-import static java.lang.Boolean.TRUE;
-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;
-import static org.jooq.impl.Keywords.K_RESTART_IDENTITY;
-import static org.jooq.impl.Keywords.K_RESTRICT;
-import static org.jooq.impl.Keywords.K_TRUNCATE_TABLE;
+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 org.jooq.*;
+import org.jooq.conf.*;
+import org.jooq.impl.*;
+import org.jooq.tools.*;
+
+import java.util.*;
-import org.jooq.Clause;
-import org.jooq.Configuration;
-import org.jooq.Context;
-import org.jooq.Record;
-import org.jooq.SQLDialect;
-import org.jooq.Table;
-import org.jooq.TruncateCascadeStep;
-import org.jooq.TruncateFinalStep;
-import org.jooq.TruncateIdentityStep;
/**
- * @author Lukas Eder
+ * The TRUNCATE statement.
*/
-final class TruncateImpl extends AbstractRowCountQuery implements
+@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
+final class TruncateImpl
+extends
+ AbstractRowCountQuery
+implements
+ TruncateIdentityStep,
+ TruncateCascadeStep,
+ TruncateFinalStep,
+ Truncate
+{
- // Cascading interface implementations for Truncate behaviour
- TruncateIdentityStep {
+ private static final long serialVersionUID = 1L;
- /**
- * Generated UID
- */
- private static final long serialVersionUID = 8904572826501186329L;
- private static final Clause[] CLAUSES = { TRUNCATE };
+ private final Table table;
+ private Boolean restartIdentity;
+ private Boolean cascade;
- private final Table table;
- private Boolean cascade;
- private Boolean restartIdentity;
+ TruncateImpl(
+ Configuration configuration,
+ Table table
+ ) {
+ this(
+ configuration,
+ table,
+ null,
+ null
+ );
+ }
- public TruncateImpl(Configuration configuration, Table table) {
+ TruncateImpl(
+ Configuration configuration,
+ Table table,
+ Boolean restartIdentity,
+ Boolean cascade
+ ) {
super(configuration);
this.table = table;
+ this.restartIdentity = restartIdentity;
+ this.cascade = cascade;
}
- final Table> $table() { return table; }
- final boolean $cascade() { return TRUE.equals(cascade); }
+ final Table $table() { return table; }
+ final Boolean $restartIdentity() { return restartIdentity; }
+ final Boolean $cascade() { return cascade; }
- // ------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// XXX: DSL API
- // ------------------------------------------------------------------------
-
+ // -------------------------------------------------------------------------
+
@Override
- public final TruncateFinalStep cascade() {
- cascade = true;
+ public final TruncateImpl restartIdentity() {
+ this.restartIdentity = true;
return this;
}
@Override
- public final TruncateFinalStep restrict() {
- cascade = false;
+ public final TruncateImpl continueIdentity() {
+ this.restartIdentity = false;
return this;
}
@Override
- public final TruncateCascadeStep restartIdentity() {
- restartIdentity = true;
+ public final TruncateImpl cascade() {
+ this.cascade = true;
return this;
}
@Override
- public final TruncateCascadeStep continueIdentity() {
- restartIdentity = false;
+ public final TruncateImpl restrict() {
+ this.cascade = false;
return this;
}
- // ------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
// XXX: QueryPart API
- // ------------------------------------------------------------------------
+ // -------------------------------------------------------------------------
+
+
+
+ private static final Clause[] CLAUSES = { Clause.TRUNCATE };
@Override
public final void accept(Context> ctx) {
@@ -136,7 +157,7 @@ final class TruncateImpl extends AbstractRowCountQuery impleme
// All other dialects do
default: {
- ctx.start(TRUNCATE_TRUNCATE)
+ ctx.start(Clause.TRUNCATE_TRUNCATE)
.visit(K_TRUNCATE_TABLE).sql(' ')
.visit(table);
@@ -162,7 +183,7 @@ final class TruncateImpl extends AbstractRowCountQuery impleme
ctx.formatSeparator()
.visit(cascade ? K_CASCADE : K_RESTRICT);
- ctx.end(TRUNCATE_TRUNCATE);
+ ctx.end(Clause.TRUNCATE_TRUNCATE);
break;
}
}
@@ -172,4 +193,6 @@ final class TruncateImpl extends AbstractRowCountQuery impleme
public final Clause[] clauses(Context> ctx) {
return CLAUSES;
}
+
+
}