@@ -482,8 +482,7 @@ public List<ColumnSetDefault> getColumnSetDefaultList() {
482482 * existing action-specific API to add or remove entries.
483483 */
484484 public List <ColumnDefaultAction > getColumnDefaults () {
485- if (operation != AlterOperation .ALTER || columnSetDefaultList == null
486- || constraintType != null && constraintSymbol != null
485+ if (!usesColumnActionBody () || columnSetDefaultList == null
487486 || columnDropDefaultList != null && !columnDropDefaultList .isEmpty ()) {
488487 return Collections .emptyList ();
489488 }
@@ -1077,7 +1076,7 @@ protected void appendBody(StringBuilder b) {
10771076 b .append (optionalSpecifier );
10781077 } else if (hasExplicitConstraintHeader ()) {
10791078 toStringConstraintAlter (b );
1080- } else if (hasAlterColumnValueActions ()) {
1079+ } else if (usesColumnActionBody ()) {
10811080 toStringAlterColumn (b );
10821081 } else if (isSimpleKeywordOperation ()) {
10831082 toStringSimpleKeyword (b );
@@ -1101,6 +1100,32 @@ private boolean hasAlterColumnValueActions() {
11011100 || columnSetVisibilityList != null && !columnSetVisibilityList .isEmpty ());
11021101 }
11031102
1103+ /**
1104+ * Whether the selected body renders ALTER COLUMN default or visibility actions. Subclasses
1105+ * overriding {@link #appendBody(StringBuilder)} must reflect their dispatch here as well.
1106+ */
1107+ protected boolean usesColumnActionBody () {
1108+ return hasAlterColumnValueActions () && !hasExplicitConstraintHeader ();
1109+ }
1110+
1111+ /**
1112+ * Whether this action currently renders its column definitions through the general body.
1113+ * Inactive column metadata is retained in the AST but must not select a different body when
1114+ * deparsing. Subclasses with their own body dispatch override this method accordingly.
1115+ */
1116+ public boolean hasActiveColumnDefinitions () {
1117+ return hasColumnDefinitionPayload () && operation != AlterOperation .UNSPECIFIC
1118+ && !hasExplicitConstraintHeader () && !usesColumnActionBody ()
1119+ && !isSimpleKeywordOperation () && !isRenameOperation () && !isDropSpecialOperation ()
1120+ && operation != AlterOperation .CONVERT && operation != AlterOperation .COLLATE
1121+ && !isPartitionOperation ();
1122+ }
1123+
1124+ /** Whether column definitions take precedence within the general body. */
1125+ protected boolean hasColumnDefinitionPayload () {
1126+ return commentText == null && columnName == null && colDataTypeList != null ;
1127+ }
1128+
11041129 /**
11051130 * Appends the common tail (parameters, index comment) shared by all ALTER expressions.
11061131 */
0 commit comments