Skip to content

Commit

Permalink
test add assertSqlCanBeParsedAndDeparsed
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-db committed Nov 23, 2024
1 parent 6328ea9 commit 9685470
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
}
}

0 comments on commit 9685470

Please sign in to comment.