@@ -444,6 +444,35 @@ public List<ColumnDefaultAction> getColumnDefaults() {
444444 return Collections .unmodifiableList (columnSetDefaultList );
445445 }
446446
447+ /**
448+ * Returns active ALTER COLUMN identity actions without treating them as data-type changes. The
449+ * list is an unmodifiable membership snapshot; its entries are the original mutable column
450+ * nodes. Request a new list after adding, removing or changing actions. Subclasses that render
451+ * a different body override this method to exclude inactive inherited column definitions.
452+ */
453+ public List <ColumnIdentityAction > getColumnIdentityActions () {
454+ if (hasExplicitConstraintHeader () || isRenameOperation () || hasAlterColumnValueActions ()) {
455+ return Collections .emptyList ();
456+ }
457+ return getColumnIdentityActionsFromDefinitions ();
458+ }
459+
460+ /** Returns identity actions when this body's general column-definition branch is active. */
461+ protected List <ColumnIdentityAction > getColumnIdentityActionsFromDefinitions () {
462+ if (operation != AlterOperation .ALTER || colDataTypeList == null
463+ || columnName != null || commentText != null ) {
464+ return Collections .emptyList ();
465+ }
466+ List <ColumnIdentityAction > actions = new ArrayList <>();
467+ for (ColumnDataType column : colDataTypeList ) {
468+ if (column .getIdentityAlterations () != null
469+ && !column .getIdentityAlterations ().isEmpty ()) {
470+ actions .add (column );
471+ }
472+ }
473+ return Collections .unmodifiableList (actions );
474+ }
475+
447476 public void addColSetVisibility (ColumnSetVisibility columnSetVisibility ) {
448477 if (columnSetVisibilityList == null ) {
449478 columnSetVisibilityList = new ArrayList <>();
@@ -994,10 +1023,7 @@ protected void appendBody(StringBuilder b) {
9941023 b .append (optionalSpecifier );
9951024 } else if (hasExplicitConstraintHeader ()) {
9961025 toStringConstraintAlter (b );
997- } else if (operation == AlterOperation .ALTER
998- && (columnDropDefaultList != null && !columnDropDefaultList .isEmpty ()
999- || columnSetDefaultList != null && !columnSetDefaultList .isEmpty ()
1000- || columnSetVisibilityList != null && !columnSetVisibilityList .isEmpty ())) {
1026+ } else if (hasAlterColumnValueActions ()) {
10011027 toStringAlterColumn (b );
10021028 } else if (isSimpleKeywordOperation ()) {
10031029 toStringSimpleKeyword (b );
@@ -1014,6 +1040,13 @@ protected void appendBody(StringBuilder b) {
10141040 }
10151041 }
10161042
1043+ private boolean hasAlterColumnValueActions () {
1044+ return operation == AlterOperation .ALTER
1045+ && (columnDropDefaultList != null && !columnDropDefaultList .isEmpty ()
1046+ || columnSetDefaultList != null && !columnSetDefaultList .isEmpty ()
1047+ || columnSetVisibilityList != null && !columnSetVisibilityList .isEmpty ());
1048+ }
1049+
10171050 /**
10181051 * Appends the common tail (parameters, index comment) shared by all ALTER expressions.
10191052 */
@@ -1711,7 +1744,8 @@ public void setHasEqualForCollate(boolean hasEqualForCollate) {
17111744 this .hasEqualForCollate = hasEqualForCollate ;
17121745 }
17131746
1714- public static final class ColumnDataType extends ColumnDefinition {
1747+ public static final class ColumnDataType extends ColumnDefinition
1748+ implements ColumnIdentityAction {
17151749
17161750 private final boolean withType ;
17171751 private boolean useSetData ;
@@ -1739,10 +1773,12 @@ public void setUsingExpression(Expression usingExpression) {
17391773 this .usingExpression = usingExpression ;
17401774 }
17411775
1776+ @ Override
17421777 public List <IdentityAlteration > getIdentityAlterations () {
17431778 return identityAlterations ;
17441779 }
17451780
1781+ @ Override
17461782 public void setIdentityAlterations (List <IdentityAlteration > identityAlterations ) {
17471783 this .identityAlterations =
17481784 identityAlterations == null ? null : new ArrayList <>(identityAlterations );
0 commit comments