[#5319] Added support for PostgreSQL
This commit is contained in:
parent
a0303b38cd
commit
89c4b40a2b
@ -457,7 +457,7 @@ public interface AlterTableStep {
|
||||
* <p>
|
||||
* This is an alias for {@link #dropColumns(Collection)}.
|
||||
*/
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL })
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
AlterTableDropStep drop(Field<?>... fields);
|
||||
|
||||
/**
|
||||
@ -466,7 +466,7 @@ public interface AlterTableStep {
|
||||
* <p>
|
||||
* This is an alias for {@link #dropColumns(Collection)}.
|
||||
*/
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL })
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
AlterTableDropStep drop(Name... fields);
|
||||
|
||||
/**
|
||||
@ -475,21 +475,21 @@ public interface AlterTableStep {
|
||||
* <p>
|
||||
* This is an alias for {@link #dropColumns(Collection)}.
|
||||
*/
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL })
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
AlterTableDropStep drop(String... fields);
|
||||
|
||||
/**
|
||||
* Add an <code>DROP COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
*/
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL })
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
AlterTableDropStep dropColumns(Field<?>... fields);
|
||||
|
||||
/**
|
||||
* Add an <code>DROP COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
*/
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL })
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
AlterTableDropStep dropColumns(Name... fields);
|
||||
|
||||
/**
|
||||
@ -512,7 +512,7 @@ public interface AlterTableStep {
|
||||
* Add an <code>DROP COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
*/
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL })
|
||||
@Support({ H2, FIREBIRD, MARIADB, MYSQL, POSTGRES })
|
||||
AlterTableDropStep dropColumns(Collection<? extends Field<?>> fields);
|
||||
|
||||
/**
|
||||
|
||||
@ -65,6 +65,7 @@ import static org.jooq.SQLDialect.MYSQL;
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
// ...
|
||||
import static org.jooq.impl.DSL.alterTable;
|
||||
import static org.jooq.impl.DSL.commentOnTable;
|
||||
import static org.jooq.impl.DSL.constraint;
|
||||
import static org.jooq.impl.DSL.field;
|
||||
@ -730,6 +731,15 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
}
|
||||
}
|
||||
|
||||
// [#5319] Compound statements to drop multiple columns in a single statement.
|
||||
if (dropColumns != null && dropColumns.size() > 1) {
|
||||
switch (family) {
|
||||
case POSTGRES:
|
||||
dropColumnsInBlock(ctx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
accept1(ctx);
|
||||
}
|
||||
|
||||
@ -1203,6 +1213,21 @@ final class AlterTableImpl extends AbstractQuery implements
|
||||
|
||||
|
||||
|
||||
|
||||
private final void dropColumnsInBlock(Context<?> ctx) {
|
||||
begin(ctx);
|
||||
|
||||
for (int i = 0; i < dropColumns.size(); i++) {
|
||||
Field<?> f = dropColumns.get(i);
|
||||
|
||||
if (i > 0)
|
||||
ctx.formatSeparator();
|
||||
|
||||
ctx.visit(alterTable(table).dropColumn(f)).sql(';');
|
||||
}
|
||||
|
||||
end(ctx);
|
||||
}
|
||||
|
||||
private final void alterColumnTypeAndNullabilityInBlock(Context<?> ctx) {
|
||||
begin(ctx);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user