mirror of
https://github.com/pikami/cosmium.git
synced 2025-12-19 17:00:37 +00:00
Support parameter in bracket #8
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -325,6 +325,7 @@ DotFieldAccess <- "." id:Identifier {
|
||||
|
||||
ArrayFieldAccess <- "[\"" id:Identifier "\"]" { return id, nil }
|
||||
/ "[" id:Integer "]" { return strconv.Itoa(id.(int)), nil }
|
||||
/ "[" id:ParameterConstant "]" { return id.(parsers.Constant).Value.(string), nil }
|
||||
|
||||
Identifier <- [a-zA-Z_][a-zA-Z0-9_]* {
|
||||
return string(c.text), nil
|
||||
|
||||
@@ -22,6 +22,20 @@ func Test_Parse_Select(t *testing.T) {
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse SELECT with query parameters as accessor", func(t *testing.T) {
|
||||
testQueryParse(
|
||||
t,
|
||||
`SELECT c.id, c[@param] FROM c`,
|
||||
parsers.SelectStmt{
|
||||
SelectItems: []parsers.SelectItem{
|
||||
{Path: []string{"c", "id"}},
|
||||
{Path: []string{"c", "@param"}},
|
||||
},
|
||||
Table: parsers.Table{Value: "c"},
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
t.Run("Should parse SELECT DISTINCT", func(t *testing.T) {
|
||||
testQueryParse(
|
||||
t,
|
||||
|
||||
Reference in New Issue
Block a user