[jOOQ/jOOQ#18043] Add MySQL and MariaDB support for ALTER TABLE .. SET
NOT NULL / DROP NOT NULL
This commit is contained in:
parent
176588668f
commit
65bb46d315
@ -167,13 +167,13 @@ public interface AlterTableAlterStep<T> {
|
||||
* Make the column <code>NOT NULL</code>.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, POSTGRES, YUGABYTEDB })
|
||||
@Support({ DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, YUGABYTEDB })
|
||||
AlterTableFinalStep setNotNull();
|
||||
|
||||
/**
|
||||
* Make the column nullable.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, POSTGRES, YUGABYTEDB })
|
||||
@Support({ DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, MARIADB, POSTGRES, YUGABYTEDB })
|
||||
AlterTableFinalStep dropNotNull();
|
||||
}
|
||||
|
||||
@ -251,6 +251,10 @@ public interface AlterTableStep {
|
||||
* Add an <code>ALTER COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
* <p>
|
||||
* Note that in some RDBMS, the current column type is required in order to
|
||||
* alter a column, so for best results, better pass it explicitly with
|
||||
* {@link #alter(Field)}.
|
||||
* <p>
|
||||
* This is an alias for {@link #alterColumn(Name)}
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@ -261,6 +265,10 @@ public interface AlterTableStep {
|
||||
* Add an <code>ALTER COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
* <p>
|
||||
* Note that in some RDBMS, the current column type is required in order to
|
||||
* alter a column, so for best results, better pass it explicitly with
|
||||
* {@link #alter(Field)}.
|
||||
* <p>
|
||||
* This is an alias for {@link #alterColumn(String)}
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@ -278,6 +286,10 @@ public interface AlterTableStep {
|
||||
/**
|
||||
* Add an <code>ALTER COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
* <p>
|
||||
* Note that in some RDBMS, the current column type is required in order to
|
||||
* alter a column, so for best results, better pass it explicitly with
|
||||
* {@link #alterColumn(Field)}.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ CLICKHOUSE, CUBRID, DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, TRINO, YUGABYTEDB })
|
||||
@ -286,6 +298,10 @@ public interface AlterTableStep {
|
||||
/**
|
||||
* Add an <code>ALTER COLUMN</code> clause to the <code>ALTER TABLE</code>
|
||||
* statement.
|
||||
* <p>
|
||||
* Note that in some RDBMS, the current column type is required in order to
|
||||
* alter a column, so for best results, better pass it explicitly with
|
||||
* {@link #alterColumn(Field)}.
|
||||
*/
|
||||
@NotNull @CheckReturnValue
|
||||
@Support({ CLICKHOUSE, CUBRID, DERBY, DUCKDB, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, TRINO, YUGABYTEDB })
|
||||
|
||||
@ -1622,6 +1622,16 @@ implements
|
||||
|
||||
|
||||
|
||||
// [#18043] Assuming users provide explicit data types of the existing column, we can reference it again
|
||||
|
||||
|
||||
case MARIADB:
|
||||
case MYSQL:
|
||||
ctx.sql(' ');
|
||||
toSQLDDLTypeDeclaration(ctx, alterColumn.getDataType());
|
||||
ctx.sql(' ').visit(alterColumnNullability.nullable() ? K_NULL : K_NOT_NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
ctx.sql(' ').visit(alterColumnNullability.nullable() ? K_DROP_NOT_NULL : K_SET_NOT_NULL);
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user