From 8c72eb8ccb0fbf3dfc781b686dc1a12cbb2798a9 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 7 Sep 2023 17:26:29 +0200 Subject: [PATCH] [jOOQ/jOOQ#2356] Support PostgreSQL multi table TRUNCATE statement --- jOOQ/src/main/java/org/jooq/DSLContext.java | 112 +++++++++--- jOOQ/src/main/java/org/jooq/impl/DSL.java | 160 +++++++++++++++--- .../java/org/jooq/impl/DefaultDSLContext.java | 46 ++++- jOOQ/src/main/java/org/jooq/impl/QOM.java | 4 +- .../main/java/org/jooq/impl/TruncateImpl.java | 33 ++-- 5 files changed, 297 insertions(+), 58 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java index 997cfe4f6d..e58db98390 100644 --- a/jOOQ/src/main/java/org/jooq/DSLContext.java +++ b/jOOQ/src/main/java/org/jooq/DSLContext.java @@ -10280,7 +10280,7 @@ public interface DSLContext extends Scope { * @see DSL#createType(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) CreateTypeStep createType(@Stringly.Name String type); /** @@ -10289,7 +10289,7 @@ public interface DSLContext extends Scope { * @see DSL#createType(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) CreateTypeStep createType(Name type); /** @@ -10298,7 +10298,7 @@ public interface DSLContext extends Scope { * @see DSL#createType(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) CreateTypeStep createType(Type type); /** @@ -10307,7 +10307,7 @@ public interface DSLContext extends Scope { * @see DSL#createTypeIfNotExists(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) CreateTypeStep createTypeIfNotExists(@Stringly.Name String type); /** @@ -10316,7 +10316,7 @@ public interface DSLContext extends Scope { * @see DSL#createTypeIfNotExists(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) CreateTypeStep createTypeIfNotExists(Name type); /** @@ -10325,7 +10325,7 @@ public interface DSLContext extends Scope { * @see DSL#createTypeIfNotExists(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) CreateTypeStep createTypeIfNotExists(Type type); /** @@ -10952,7 +10952,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(@Stringly.Name String types); /** @@ -10961,7 +10961,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(Name types); /** @@ -10970,7 +10970,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(Type types); /** @@ -10979,7 +10979,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(String...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(@Stringly.Name String... types); /** @@ -10988,7 +10988,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(Name...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(Name... types); /** @@ -10997,7 +10997,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(Type...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(Type... types); /** @@ -11006,7 +11006,7 @@ public interface DSLContext extends Scope { * @see DSL#dropType(Collection) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropType(Collection> types); /** @@ -11015,7 +11015,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(@Stringly.Name String types); /** @@ -11024,7 +11024,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(Name types); /** @@ -11033,7 +11033,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(Type types); /** @@ -11042,7 +11042,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(String...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(@Stringly.Name String... types); /** @@ -11051,7 +11051,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(Name...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(Name... types); /** @@ -11060,7 +11060,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(Type...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(Type... types); /** @@ -11069,7 +11069,7 @@ public interface DSLContext extends Scope { * @see DSL#dropTypeIfExists(Collection) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) DropTypeStep dropTypeIfExists(Collection> types); /** @@ -11344,6 +11344,42 @@ public interface DSLContext extends Scope { @Support TruncateIdentityStep truncate(Table table); + /** + * The TRUNCATE statement. + * + * @see DSL#truncate(String...) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncate(@Stringly.Name String... table); + + /** + * The TRUNCATE statement. + * + * @see DSL#truncate(Name...) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncate(Name... table); + + /** + * The TRUNCATE statement. + * + * @see DSL#truncate(Table...) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncate(Table... table); + + /** + * The TRUNCATE statement. + * + * @see DSL#truncate(Collection) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncate(Collection> table); + /** * The TRUNCATE TABLE statement. * @@ -11371,6 +11407,42 @@ public interface DSLContext extends Scope { @Support TruncateIdentityStep truncateTable(Table table); + /** + * The TRUNCATE TABLE statement. + * + * @see DSL#truncateTable(String...) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncateTable(@Stringly.Name String... table); + + /** + * The TRUNCATE TABLE statement. + * + * @see DSL#truncateTable(Name...) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncateTable(Name... table); + + /** + * The TRUNCATE TABLE statement. + * + * @see DSL#truncateTable(Table...) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncateTable(Table... table); + + /** + * The TRUNCATE TABLE statement. + * + * @see DSL#truncateTable(Collection) + */ + @NotNull @CheckReturnValue + @Support + TruncateIdentityStep truncateTable(Collection> table); + diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 12c3c3e5dc..73e895124a 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -8779,7 +8779,7 @@ public class DSL { * @see DSLContext#createType(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.CreateTypeStep createType(@Stringly.Name String type) { return dsl().createType(type); } @@ -8794,7 +8794,7 @@ public class DSL { * @see DSLContext#createType(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.CreateTypeStep createType(Name type) { return dsl().createType(type); } @@ -8809,7 +8809,7 @@ public class DSL { * @see DSLContext#createType(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.CreateTypeStep createType(Type type) { return dsl().createType(type); } @@ -8824,7 +8824,7 @@ public class DSL { * @see DSLContext#createTypeIfNotExists(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.CreateTypeStep createTypeIfNotExists(@Stringly.Name String type) { return dsl().createTypeIfNotExists(type); } @@ -8839,7 +8839,7 @@ public class DSL { * @see DSLContext#createTypeIfNotExists(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.CreateTypeStep createTypeIfNotExists(Name type) { return dsl().createTypeIfNotExists(type); } @@ -8854,7 +8854,7 @@ public class DSL { * @see DSLContext#createTypeIfNotExists(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.CreateTypeStep createTypeIfNotExists(Type type) { return dsl().createTypeIfNotExists(type); } @@ -9883,7 +9883,7 @@ public class DSL { * @see DSLContext#dropType(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(@Stringly.Name String types) { return dsl().dropType(types); } @@ -9898,7 +9898,7 @@ public class DSL { * @see DSLContext#dropType(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(Name types) { return dsl().dropType(types); } @@ -9913,7 +9913,7 @@ public class DSL { * @see DSLContext#dropType(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(Type types) { return dsl().dropType(types); } @@ -9928,7 +9928,7 @@ public class DSL { * @see DSLContext#dropType(String...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(@Stringly.Name String... types) { return dsl().dropType(types); } @@ -9943,7 +9943,7 @@ public class DSL { * @see DSLContext#dropType(Name...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(Name... types) { return dsl().dropType(types); } @@ -9958,7 +9958,7 @@ public class DSL { * @see DSLContext#dropType(Type...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(Type... types) { return dsl().dropType(types); } @@ -9973,7 +9973,7 @@ public class DSL { * @see DSLContext#dropType(Collection) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropType(Collection> types) { return dsl().dropType(types); } @@ -9988,7 +9988,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(String) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(@Stringly.Name String types) { return dsl().dropTypeIfExists(types); } @@ -10003,7 +10003,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(Name) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(Name types) { return dsl().dropTypeIfExists(types); } @@ -10018,7 +10018,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(Type) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(Type types) { return dsl().dropTypeIfExists(types); } @@ -10033,7 +10033,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(String...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(@Stringly.Name String... types) { return dsl().dropTypeIfExists(types); } @@ -10048,7 +10048,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(Name...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(Name... types) { return dsl().dropTypeIfExists(types); } @@ -10063,7 +10063,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(Type...) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(Type... types) { return dsl().dropTypeIfExists(types); } @@ -10078,7 +10078,7 @@ public class DSL { * @see DSLContext#dropTypeIfExists(Collection) */ @NotNull @CheckReturnValue - @Support({ H2, POSTGRES, YUGABYTEDB }) + @Support({ DUCKDB, H2, POSTGRES, YUGABYTEDB }) public static org.jooq.DropTypeStep dropTypeIfExists(Collection> types) { return dsl().dropTypeIfExists(types); } @@ -10523,6 +10523,66 @@ public class DSL { return dsl().truncate(table); } + /** + * The TRUNCATE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncate(String...) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncate(@Stringly.Name String... table) { + return dsl().truncate(table); + } + + /** + * The TRUNCATE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncate(Name...) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncate(Name... table) { + return dsl().truncate(table); + } + + /** + * The TRUNCATE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncate(Table...) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncate(Table... table) { + return dsl().truncate(table); + } + + /** + * The TRUNCATE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncate(Collection) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncate(Collection> table) { + return dsl().truncate(table); + } + /** * The TRUNCATE TABLE statement. *

@@ -10568,6 +10628,66 @@ public class DSL { return dsl().truncateTable(table); } + /** + * The TRUNCATE TABLE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncateTable(String...) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncateTable(@Stringly.Name String... table) { + return dsl().truncateTable(table); + } + + /** + * The TRUNCATE TABLE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncateTable(Name...) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncateTable(Name... table) { + return dsl().truncateTable(table); + } + + /** + * The TRUNCATE TABLE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncateTable(Table...) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncateTable(Table... table) { + return dsl().truncateTable(table); + } + + /** + * The TRUNCATE TABLE statement. + *

+ * Unlike statement construction methods in the {@link DSLContext} API, this + * creates an unattached, and thus not directly renderable or executable + * statement. It can be used as a subquery or nested in procedural logic. + * + * @see DSLContext#truncateTable(Collection) + */ + @NotNull @CheckReturnValue + @Support + public static org.jooq.TruncateIdentityStep truncateTable(Collection> table) { + return dsl().truncateTable(table); + } + diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java index f95b543879..946802fb5d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java @@ -3999,17 +3999,37 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri @Override public org.jooq.TruncateIdentityStep truncate(@Stringly.Name String table) { - return new TruncateImpl(configuration(), DSL.table(DSL.name(table))); + return new TruncateImpl(configuration(), Arrays.asList(DSL.table(table))); } @Override public org.jooq.TruncateIdentityStep truncate(Name table) { - return new TruncateImpl(configuration(), DSL.table(table)); + return new TruncateImpl(configuration(), Arrays.asList(DSL.table(table))); } @Override public org.jooq.TruncateIdentityStep truncate(Table table) { - return new TruncateImpl(configuration(), table); + return new TruncateImpl(configuration(), Arrays.asList(table)); + } + + @Override + public org.jooq.TruncateIdentityStep truncate(@Stringly.Name String... table) { + return new TruncateImpl(configuration(), Tools.map(table, e -> DSL.table(e))); + } + + @Override + public org.jooq.TruncateIdentityStep truncate(Name... table) { + return new TruncateImpl(configuration(), Tools.map(table, e -> DSL.table(e))); + } + + @Override + public org.jooq.TruncateIdentityStep truncate(Table... table) { + return new TruncateImpl(configuration(), Arrays.asList(table)); + } + + @Override + public org.jooq.TruncateIdentityStep truncate(Collection> table) { + return new TruncateImpl(configuration(), new QueryPartList<>(table)); } @Override @@ -4026,6 +4046,26 @@ public class DefaultDSLContext extends AbstractScope implements DSLContext, Seri public org.jooq.TruncateIdentityStep truncateTable(Table table) { return truncate(table); } + + @Override + public org.jooq.TruncateIdentityStep truncateTable(@Stringly.Name String... table) { + return truncate(table); + } + + @Override + public org.jooq.TruncateIdentityStep truncateTable(Name... table) { + return truncate(table); + } + + @Override + public org.jooq.TruncateIdentityStep truncateTable(Table... table) { + return truncate(table); + } + + @Override + public org.jooq.TruncateIdentityStep truncateTable(Collection> table) { + return truncate(table); + } diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index 7c72525025..ca721c512d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -2674,11 +2674,11 @@ public final class QOM { //permits // TruncateImpl { - @NotNull Table $table(); + @NotNull UnmodifiableList> $table(); @Nullable IdentityRestartOption $restartIdentity(); @Nullable Cascade $cascade(); @CheckReturnValue - @NotNull Truncate $table(Table table); + @NotNull Truncate $table(Collection> table); @CheckReturnValue @NotNull Truncate $restartIdentity(IdentityRestartOption restartIdentity); @CheckReturnValue diff --git a/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java b/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java index db2a7a4826..7ffe68c5ef 100644 --- a/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/TruncateImpl.java @@ -64,7 +64,7 @@ import java.util.stream.*; /** * The TRUNCATE statement. */ -@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +@SuppressWarnings({ "rawtypes", "unused" }) final class TruncateImpl extends AbstractDDLQuery @@ -76,13 +76,13 @@ implements org.jooq.Truncate { - final Table table; - IdentityRestartOption restartIdentity; - Cascade cascade; + final QueryPartListView> table; + IdentityRestartOption restartIdentity; + Cascade cascade; TruncateImpl( Configuration configuration, - Table table + Collection> table ) { this( configuration, @@ -94,13 +94,13 @@ implements TruncateImpl( Configuration configuration, - Table table, + Collection> table, IdentityRestartOption restartIdentity, Cascade cascade ) { super(configuration); - this.table = table; + this.table = new QueryPartList<>(table); this.restartIdentity = restartIdentity; this.cascade = cascade; } @@ -152,7 +152,14 @@ implements case FIREBIRD: case IGNITE: case SQLITE: { - ctx.visit(delete(table)); + if (table.size() == 1) { + ctx.visit(delete(table.get(0))); + } + else { + ctx.sql("[Cannot emulate multi-table truncate using DELETE yet]"); + log.warn("Multi table truncate", "Cannot emulate multi-table truncate using DELETE yet"); + } + break; } @@ -202,8 +209,8 @@ implements // ------------------------------------------------------------------------- @Override - public final Table $table() { - return table; + public final UnmodifiableList> $table() { + return QOM.unmodifiable(table); } @Override @@ -217,7 +224,7 @@ implements } @Override - public final QOM.Truncate $table(Table newValue) { + public final QOM.Truncate $table(Collection> newValue) { return $constructor().apply(newValue, $restartIdentity(), $cascade()); } @@ -231,8 +238,8 @@ implements return $constructor().apply($table(), $restartIdentity(), newValue); } - public final Function3, ? super IdentityRestartOption, ? super Cascade, ? extends QOM.Truncate> $constructor() { - return (a1, a2, a3) -> new TruncateImpl(configuration(), a1, a2, a3); + public final Function3>, ? super IdentityRestartOption, ? super Cascade, ? extends QOM.Truncate> $constructor() { + return (a1, a2, a3) -> new TruncateImpl(configuration(), (Collection>) a1, a2, a3); }