Skip to content

Commit

Permalink
[14.0] Fix JSON functions parsing (#11624)
Browse files Browse the repository at this point in the history
* refactor: clean up the JSON AST structs a little

Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>

* feat: add failing test

Signed-off-by: Manan Gupta <[email protected]>

Signed-off-by: Andres Taylor <[email protected]>
Signed-off-by: Manan Gupta <[email protected]>
Co-authored-by: Andres Taylor <[email protected]>
  • Loading branch information
GuptaManan100 and systay authored Nov 3, 2022
1 parent 01ec41f commit bb45fc8
Show file tree
Hide file tree
Showing 11 changed files with 5,847 additions and 6,893 deletions.
19 changes: 8 additions & 11 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2519,23 +2519,20 @@ type (
Expr Expr
}

// JSONPathParam is used to store the path used as arguments in different JSON functions
JSONPathParam Expr

// JSONContainsExpr represents the function and arguments for JSON_CONTAINS()
// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains
JSONContainsExpr struct {
Target Expr
Candidate Expr
PathList []JSONPathParam
PathList []Expr
}

// JSONContainsPathExpr represents the function and arguments for JSON_CONTAINS_PATH()
// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-contains-path
JSONContainsPathExpr struct {
JSONDoc Expr
OneOrAll Expr
PathList []JSONPathParam
PathList []Expr
}

// JSONContainsPathType is an enum to get types of Trim
Expand All @@ -2545,14 +2542,14 @@ type (
// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-extract
JSONExtractExpr struct {
JSONDoc Expr
PathList []JSONPathParam
PathList []Expr
}

// JSONKeysExpr represents the function and arguments for JSON_KEYS()
// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-keys
JSONKeysExpr struct {
JSONDoc Expr
PathList []JSONPathParam
JSONDoc Expr
Path Expr
}

// JSONOverlapsExpr represents the function and arguments for JSON_OVERLAPS()
Expand All @@ -2569,14 +2566,14 @@ type (
OneOrAll Expr
SearchStr Expr
EscapeChar Expr
PathList []JSONPathParam
PathList []Expr
}

// JSONValueExpr represents the function and arguments for JSON_VALUE()
// For more information, see https://dev.mysql.com/doc/refman/8.0/en/json-search-functions.html#function_json-value
JSONValueExpr struct {
JSONDoc Expr
Path JSONPathParam
Path Expr
ReturningType *ConvertType
EmptyOnResponse *JtOnResponse
ErrorOnResponse *JtOnResponse
Expand Down Expand Up @@ -2608,7 +2605,7 @@ type (
JSONAttributesExpr struct {
Type JSONAttributeType
JSONDoc Expr
Path JSONPathParam
Path Expr
}

// JSONAttributeType is an enum to get types of TrimFunc.
Expand Down
178 changes: 11 additions & 167 deletions go/vt/sqlparser/ast_clone.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bb45fc8

Please sign in to comment.