You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by mi...@apache.org on 2023/04/11 09:41:44 UTC

[shardingsphere-on-cloud] branch main updated: chore: add ifExists to ast (#304)

This is an automated email from the ASF dual-hosted git repository.

miaoliyao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git


The following commit(s) were added to refs/heads/main by this push:
     new 640ea15  chore: add ifExists to ast (#304)
640ea15 is described below

commit 640ea15013ae25ffad234f7e5f60849740d2fe28
Author: Jack <87...@qq.com>
AuthorDate: Tue Apr 11 17:41:38 2023 +0800

    chore: add ifExists to ast (#304)
    
    Signed-off-by: wangbo <wa...@sphere-ex.com>
    Co-authored-by: wangbo <wa...@sphere-ex.com>
---
 shardingsphere-operator/pkg/distsql/visitor/rdl_visitor.go | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/shardingsphere-operator/pkg/distsql/visitor/rdl_visitor.go b/shardingsphere-operator/pkg/distsql/visitor/rdl_visitor.go
index b97955a..3adaeaa 100644
--- a/shardingsphere-operator/pkg/distsql/visitor/rdl_visitor.go
+++ b/shardingsphere-operator/pkg/distsql/visitor/rdl_visitor.go
@@ -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 {
@@ -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() {