mirror of
https://github.com/pikami/cosmium.git
synced 2026-08-11 07:37:00 +01:00
Fix ExcludedKeywords parsing
This commit is contained in:
@@ -99,6 +99,17 @@ func Test_Documents(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Should query document with 'orderByItems' alias", func(t *testing.T) {
|
||||||
|
testCosmosQuery(t, collectionClient,
|
||||||
|
`SELECT c.id, c["pk"] AS orderByItems FROM c ORDER BY c.id`,
|
||||||
|
nil,
|
||||||
|
[]interface{}{
|
||||||
|
map[string]interface{}{"id": "12345", "orderByItems": "123"},
|
||||||
|
map[string]interface{}{"id": "67890", "orderByItems": "456"},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Should query VALUE array", func(t *testing.T) {
|
t.Run("Should query VALUE array", func(t *testing.T) {
|
||||||
testCosmosQuery(t, collectionClient,
|
testCosmosQuery(t, collectionClient,
|
||||||
"SELECT VALUE [c.id, c[\"pk\"]] FROM c ORDER BY c.id",
|
"SELECT VALUE [c.id, c[\"pk\"]] FROM c ORDER BY c.id",
|
||||||
|
|||||||
+1654
-1604
File diff suppressed because it is too large
Load Diff
@@ -387,7 +387,11 @@ AsClause <- (ws As)? ws !ExcludedKeywords alias:Identifier {
|
|||||||
return alias, nil
|
return alias, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ExcludedKeywords <- Select / Top / As / From / In / Join / Exists / Where / And / Or / Not / GroupBy / OrderBy / Offset
|
ExcludedKeywords <- (
|
||||||
|
Select / Top / As / From / In / Join / Exists / Where / And / Or / Not / Offset /
|
||||||
|
("GROUP"i wss "BY"i) /
|
||||||
|
("ORDER"i wss "BY"i)
|
||||||
|
) ![a-zA-Z0-9_]
|
||||||
|
|
||||||
DotFieldAccess <- "." id:Identifier {
|
DotFieldAccess <- "." id:Identifier {
|
||||||
return id, nil
|
return id, nil
|
||||||
|
|||||||
@@ -159,6 +159,26 @@ func Test_Parse_Select(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Should parse SELECT with orderByItems alias", func(t *testing.T) {
|
||||||
|
testQueryParse(
|
||||||
|
t,
|
||||||
|
`SELECT c.id, c["pk"] AS orderByItems FROM c ORDER BY c.id`,
|
||||||
|
parsers.SelectStmt{
|
||||||
|
SelectItems: []parsers.SelectItem{
|
||||||
|
{Path: []string{"c", "id"}},
|
||||||
|
{Alias: "orderByItems", Path: []string{"c", "pk"}},
|
||||||
|
},
|
||||||
|
Table: parsers.Table{SelectItem: testutils.SelectItem_Path("c")},
|
||||||
|
OrderExpressions: []parsers.OrderExpression{
|
||||||
|
{
|
||||||
|
SelectItem: testutils.SelectItem_Path("c", "id"),
|
||||||
|
Direction: parsers.OrderDirectionAsc,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Should parse SELECT object", func(t *testing.T) {
|
t.Run("Should parse SELECT object", func(t *testing.T) {
|
||||||
testQueryParse(
|
testQueryParse(
|
||||||
t,
|
t,
|
||||||
|
|||||||
Reference in New Issue
Block a user