Skip to content

Commit

Permalink
revert split member of
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongjiwei committed Dec 12, 2022
1 parent dfc80a6 commit 2eadf13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions parser/ast/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,18 +497,18 @@ func (n *FuncCallExpr) customRestore(ctx *format.RestoreCtx) (bool, error) {
if specialLiteral != "" {
ctx.WritePlain(specialLiteral)
if err := n.Args[0].Restore(ctx); err != nil {
return true, errors.Annotatef(err, "An error occurred while restore FuncCastExpr.Expr")
return true, errors.Annotatef(err, "An error occurred while restore FuncCallExpr.Expr")
}
return true, nil
}
if n.FnName.L == JSONMemberOf {
if err := n.Args[0].Restore(ctx); err != nil {
return true, errors.Annotatef(err, "An error occurred while restore FuncCallExpr.(WEIGHT_STRING).Args[0]")
return true, errors.Annotatef(err, "An error occurred while restore FuncCallExpr.(MEMBER OF).Args[0]")
}
ctx.WriteKeyWord(" MEMBER OF ")
ctx.WritePlain("(")
if err := n.Args[1].Restore(ctx); err != nil {
return true, errors.Annotatef(err, "An error occurred while restore FuncCallExpr.(WEIGHT_STRING).Args[1]")
return true, errors.Annotatef(err, "An error occurred while restore FuncCallExpr.(MEMBER OF).Args[1]")
}
ctx.WritePlain(")")
return true, nil
Expand Down
1 change: 1 addition & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2148,6 +2148,7 @@ func TestBuiltin(t *testing.T) {

{`SELECT 1 member of (a)`, true, "SELECT 1 MEMBER OF (`a`)"},
{`SELECT 1 member of a`, false, ""},
{`SELECT 1 member a`, false, ""},
{`SELECT 1 not member of a`, false, ""},
{`SELECT 1 member of (1+1)`, false, ""},
{`SELECT concat('a') member of (cast(1 as char(1)))`, true, "SELECT CONCAT(_UTF8MB4'a') MEMBER OF (CAST(1 AS CHAR(1)))"},
Expand Down

0 comments on commit 2eadf13

Please sign in to comment.