diff --git a/jOOQ/src/main/java/org/jooq/AlterTableAlterStep.java b/jOOQ/src/main/java/org/jooq/AlterTableAlterStep.java index 833e38a0ed..0fb1a8ffe2 100644 --- a/jOOQ/src/main/java/org/jooq/AlterTableAlterStep.java +++ b/jOOQ/src/main/java/org/jooq/AlterTableAlterStep.java @@ -167,13 +167,13 @@ public interface AlterTableAlterStep { * Make the column NOT NULL. */ @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(); } diff --git a/jOOQ/src/main/java/org/jooq/AlterTableStep.java b/jOOQ/src/main/java/org/jooq/AlterTableStep.java index 04630997df..a5baf5159d 100644 --- a/jOOQ/src/main/java/org/jooq/AlterTableStep.java +++ b/jOOQ/src/main/java/org/jooq/AlterTableStep.java @@ -251,6 +251,10 @@ public interface AlterTableStep { * Add an ALTER COLUMN clause to the ALTER TABLE * statement. *

+ * 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)}. + *

* This is an alias for {@link #alterColumn(Name)} */ @NotNull @CheckReturnValue @@ -261,6 +265,10 @@ public interface AlterTableStep { * Add an ALTER COLUMN clause to the ALTER TABLE * statement. *

+ * 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)}. + *

* This is an alias for {@link #alterColumn(String)} */ @NotNull @CheckReturnValue @@ -278,6 +286,10 @@ public interface AlterTableStep { /** * Add an ALTER COLUMN clause to the ALTER TABLE * statement. + *

+ * 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 ALTER COLUMN clause to the ALTER TABLE * statement. + *

+ * 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 }) diff --git a/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java b/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java index 32206e5db0..7df86dd178 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/AlterTableImpl.java @@ -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;