Skip to content

Commit

Permalink
chore: add ifExists to ast (#304)
Browse files Browse the repository at this point in the history
Signed-off-by: wangbo <wangbo@sphere-ex.com>
Co-authored-by: wangbo <wangbo@sphere-ex.com>
  • Loading branch information
wbtlb and wangbo authored Apr 11, 2023
1 parent 0d3b1e9 commit 640ea15
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions shardingsphere-operator/pkg/distsql/visitor/rdl_visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ func (v *Visitor) VisitIfNotExists(ctx *parser.IfNotExistsContext) *ast.IfNotExi
}
}

func (v *Visitor) VisitIfExists(ctx *parser.IfExistsContext) *ast.IfExists {
return &ast.IfExists{
IfExists: fmt.Sprintf("%s %s", ctx.IF().GetText(), ctx.EXISTS().GetText()),
}
}

func (v *Visitor) VisitAlterEncryptRule(ctx *parser.AlterEncryptRuleContext) *ast.AlterEncryptRule {
stmt := &ast.AlterEncryptRule{}
if ctx.AllEncryptRuleDefinition() != nil {
Expand All @@ -66,10 +72,9 @@ func (v *Visitor) VisitAlterEncryptRule(ctx *parser.AlterEncryptRuleContext) *as
func (v *Visitor) VisitDropEncryptRule(ctx *parser.DropEncryptRuleContext) *ast.DropEncryptRule {
stmt := &ast.DropEncryptRule{}

// TODO: Add IfExists to AST
// if ctx.IfExists() != nil {
// stmt.IfExists = v.VisitIfExists(ctx.IfExists().(*parser.IfExistsContext))
// }
if ctx.IfExists() != nil {
stmt.IfExists = v.VisitIfExists(ctx.IfExists().(*parser.IfExistsContext))
}

if ctx.AllTableName() != nil {
for _, tableName := range ctx.AllTableName() {
Expand Down

0 comments on commit 640ea15

Please sign in to comment.