Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 19, 2024
1 parent 97409a5 commit d584a44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion lib/antlr/rename_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ func processRenameTable(ctx *generated.RenameTableContext) ([]Event, error) {
case *generated.RenameTableClauseContext:
var allTableNames []string
for _, tableName := range castedChild.AllTableName() {
allTableNames = append(allTableNames, tableName.GetText())
parsedTableName, err := getTableNameFromNode(tableName)
if err != nil {
return nil, fmt.Errorf("failed to get table name: %w", err)
}

allTableNames = append(allTableNames, parsedTableName)
}

// Must be at least two table names
Expand Down
6 changes: 3 additions & 3 deletions lib/antlr/rename_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ func TestRenameTable(t *testing.T) {
}
{
// Another one table variant
events, err := Parse(`RENAME TABLE current_db.tbl_name TO other_db.tbl_name;`)
events, err := Parse(`RENAME TABLE current_db.tbl_name TO current_db.tbl_name;`)
assert.NoError(t, err)
assert.Len(t, events, 1)

renameTableEvent, isOk := events[0].(RenameTableEvent)
assert.True(t, isOk)

assert.Equal(t, "current_db.tbl_name", renameTableEvent.GetTable())
assert.Equal(t, "other_db.tbl_name", renameTableEvent.GetNewTableName())
assert.Equal(t, "tbl_name", renameTableEvent.GetTable())
assert.Equal(t, "tbl_name", renameTableEvent.GetNewTableName())
}
{
// Multiple tables
Expand Down

0 comments on commit d584a44

Please sign in to comment.