Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test to cover alter table rename without table keyword #909

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@ private void parseAlterTableByRename(String originalTableName, MySqlParser.Alter
for(ParseTree alterByRenameChildren: tree.children) {
if(alterByRenameChildren instanceof MySqlParser.UidContext) {
newTableName = alterByRenameChildren.getText();
} else if(alterByRenameChildren instanceof MySqlParser.FullIdContext) {
newTableName = alterByRenameChildren.getText();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,24 @@ public void dropMultipleTables() {
Assert.assertTrue(clickHouseQuery.toString().equalsIgnoreCase("drop table add_test,add_test2"));
}

@Test
public void renameTableWithoutTableKeyword() {
StringBuffer clickHouseQuery = new StringBuffer();

String sql = "ALTER TABLE employees.old_table RENAME employees.new_table";
mySQLDDLParserService.parseSql(sql, "table1", clickHouseQuery);

Assert.assertTrue(clickHouseQuery.toString().equalsIgnoreCase("rename table employees.old_table to employees.new_table"));
}

@Test
public void renameTableWithTableKeyword() {
StringBuffer clickHouseQuery = new StringBuffer();
String sql = "ALTER TABLE old_table RENAME new_table";
mySQLDDLParserService.parseSql(sql, "table1", clickHouseQuery);
Assert.assertTrue(clickHouseQuery.toString().equalsIgnoreCase("rename table employees.old_table to employees.new_table"));
}

@Test
public void renameTable() {
StringBuffer clickHouseQuery = new StringBuffer();
Expand Down
Loading