Skip to content

Commit

Permalink
fixes #984
Browse files Browse the repository at this point in the history
  • Loading branch information
wumpz committed May 16, 2020
1 parent 8289406 commit 60ac16a
Show file tree
Hide file tree
Showing 4 changed files with 222 additions and 181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public class AlterExpression {

private List<ConstraintState> constraints;
private List<String> parameters;
private String commentText;

public String getCommentText() {
return commentText;
}

public void setCommentText(String commentText) {
this.commentText = commentText;
}

public AlterOperation getOperation() {
return operation;
Expand Down Expand Up @@ -116,7 +125,7 @@ public void addColDataType(ColumnDataType columnDataType) {
}
colDataTypeList.add(columnDataType);
}

public void addColDropNotNull(ColumnDropNotNull columnDropNotNull) {
if (columnDropNotNullList == null) {
columnDropNotNullList = new ArrayList<ColumnDropNotNull>();
Expand Down Expand Up @@ -242,7 +251,12 @@ public String toString() {

b.append(operation).append(" ");

if (columnName != null) {
if (commentText != null) {
if (columnName != null) {
b.append(columnName).append(" COMMENT ");
}
b.append(commentText);
} else if (columnName != null) {
b.append("COLUMN ");
if (operation == AlterOperation.RENAME) {
b.append(columnOldName).append(" TO ");
Expand All @@ -263,7 +277,7 @@ public String toString() {
if (colDataTypeList.size() > 1) {
b.append(")");
}
} else if ( getColumnDropNotNullList() != null) {
} else if (getColumnDropNotNullList() != null) {
if (operation == AlterOperation.CHANGE) {
if (optionalSpecifier != null) {
b.append(optionalSpecifier).append(" ");
Expand Down Expand Up @@ -325,6 +339,7 @@ public String toString() {
}

public final static class ColumnDataType extends ColumnDefinition {

private final boolean withType;

public ColumnDataType(String columnName, boolean withType, ColDataType colDataType, List<String> columnSpecs) {
Expand Down Expand Up @@ -358,8 +373,8 @@ public boolean isWithNot() {

@Override
public String toString() {
return columnName + " DROP" +
(withNot ? " NOT " : " ") + "NULL";
return columnName + " DROP"
+ (withNot ? " NOT " : " ") + "NULL";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
package net.sf.jsqlparser.statement.alter;

public enum AlterOperation {
ADD, ALTER, DROP, MODIFY, CHANGE, ALGORITHM, RENAME;
ADD, ALTER, DROP, MODIFY, CHANGE, ALGORITHM, RENAME, COMMENT;
}
Loading

0 comments on commit 60ac16a

Please sign in to comment.