parser: use ExpressionListOpt for json functions. (#3362)
This commit is contained in:
@ -3642,28 +3642,17 @@ FunctionCallNonKeyword:
|
||||
{
|
||||
$$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1), Args: $3.([]ast.ExprNode)}
|
||||
}
|
||||
| "JSON_EXTRACT" '(' Expression ',' ExpressionList ')'
|
||||
| "JSON_EXTRACT" '(' ExpressionListOpt ')'
|
||||
{
|
||||
var args = []ast.ExprNode{$3.(ast.ExprNode)}
|
||||
args = append(args, $5.([]ast.ExprNode)...)
|
||||
$$ = &ast.FuncCallExpr{
|
||||
FnName: model.NewCIStr($1),
|
||||
Args: args,
|
||||
}
|
||||
$$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1), Args: $3.([]ast.ExprNode)}
|
||||
}
|
||||
| "JSON_UNQUOTE" '(' Expression ')'
|
||||
| "JSON_UNQUOTE" '(' ExpressionListOpt ')'
|
||||
{
|
||||
$$ = &ast.FuncCallExpr{
|
||||
FnName: model.NewCIStr($1),
|
||||
Args: []ast.ExprNode{$3.(ast.ExprNode)},
|
||||
}
|
||||
$$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1), Args: $3.([]ast.ExprNode)}
|
||||
}
|
||||
| "JSON_TYPE" '(' Expression ')'
|
||||
| "JSON_TYPE" '(' ExpressionListOpt ')'
|
||||
{
|
||||
$$ = &ast.FuncCallExpr{
|
||||
FnName: model.NewCIStr($1),
|
||||
Args: []ast.ExprNode{$3.(ast.ExprNode)},
|
||||
}
|
||||
$$ = &ast.FuncCallExpr{FnName: model.NewCIStr($1), Args: $3.([]ast.ExprNode)}
|
||||
}
|
||||
|
||||
GetFormatSelector:
|
||||
|
||||
@ -1026,6 +1026,12 @@ func (s *testParserSuite) TestBuiltin(c *C) {
|
||||
{`SELECT UNCOMPRESS('any string');`, true},
|
||||
{`SELECT UNCOMPRESSED_LENGTH(@compressed_string);`, true},
|
||||
{`SELECT VALIDATE_PASSWORD_STRENGTH(@str);`, true},
|
||||
|
||||
// For JSON functions.
|
||||
{`SELECT JSON_EXTRACT();`, true},
|
||||
{`SELECT JSON_UNQUOTE();`, true},
|
||||
{`SELECT JSON_TYPE('[123]');`, true},
|
||||
{`SELECT JSON_TYPE();`, true},
|
||||
}
|
||||
s.RunTest(c, table)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user