diff --git a/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java b/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java index 68f3b112b..1f26a70c7 100644 --- a/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java +++ b/src/main/java/net/sf/jsqlparser/statement/alter/AlterExpression.java @@ -463,6 +463,8 @@ public String toString() { if (operation == AlterOperation.UNSPECIFIC) { b.append(optionalSpecifier); + } else if (operation == AlterOperation.SET_TABLE_OPTION) { + b.append(tableOption); } else if (getOldIndex() != null) { b.append("RENAME"); switch (operation) { diff --git a/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java b/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java index eea0e1c43..005961a3d 100644 --- a/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java +++ b/src/test/java/net/sf/jsqlparser/statement/alter/AlterTest.java @@ -30,6 +30,7 @@ import java.util.List; import static net.sf.jsqlparser.test.TestUtils.*; +import static net.sf.jsqlparser.test.TestUtils.assertSqlCanBeParsedAndDeparsed; import static org.junit.jupiter.api.Assertions.*; public class AlterTest { @@ -1290,6 +1291,8 @@ public void testIssue2114AlterTableEncryption() throws JSQLParserException { AlterExpression encryptionExp = alterExpressions.get(0); assertEquals(AlterOperation.SET_TABLE_OPTION, encryptionExp.getOperation()); assertEquals(encryptionExp.getTableOption(), "ENCRYPTION = 'Y'"); + + assertSqlCanBeParsedAndDeparsed(sql); } @Test @@ -1305,6 +1308,7 @@ public void testIssue2114AlterTableEncryptionWithoutEqual() throws JSQLParserExc AlterExpression encryptionExp = alterExpressions.get(0); assertEquals(AlterOperation.SET_TABLE_OPTION, encryptionExp.getOperation()); assertEquals(encryptionExp.getTableOption(), "ENCRYPTION 'N'"); + assertSqlCanBeParsedAndDeparsed(sql); } @Test @@ -1320,6 +1324,7 @@ public void testIssue2114AlterTableAutoIncrement() throws JSQLParserException { AlterExpression autoIncrementExp = alterExpressions.get(0); assertEquals(AlterOperation.SET_TABLE_OPTION, autoIncrementExp.getOperation()); assertEquals(autoIncrementExp.getTableOption(), "AUTO_INCREMENT = 101"); + assertSqlCanBeParsedAndDeparsed(sql); } @Test @@ -1335,5 +1340,6 @@ public void testIssue2114AlterTableEngine() throws JSQLParserException { AlterExpression engineExp = alterExpressions.get(0); assertEquals(AlterOperation.SET_TABLE_OPTION, engineExp.getOperation()); assertEquals(engineExp.getTableOption(), "ENGINE = InnoDB"); + assertSqlCanBeParsedAndDeparsed(sql); } }