mirror of
https://github.com/pikami/cosmium.git
synced 2026-04-19 04:52:54 +01:00
Fix 'NOT (bool)' statements
This commit is contained in:
@@ -143,6 +143,34 @@ func Test_Parse(t *testing.T) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Should parse NOT with parentheses", func(t *testing.T) {
|
||||||
|
testQueryParse(
|
||||||
|
t,
|
||||||
|
`SELECT c.id FROM c WHERE NOT (c.id IN ("123", "456"))`,
|
||||||
|
parsers.SelectStmt{
|
||||||
|
SelectItems: []parsers.SelectItem{
|
||||||
|
{Path: []string{"c", "id"}, Type: parsers.SelectItemTypeField},
|
||||||
|
},
|
||||||
|
Table: parsers.Table{SelectItem: testutils.SelectItem_Path("c")},
|
||||||
|
Filters: parsers.SelectItem{
|
||||||
|
Type: parsers.SelectItemTypeFunctionCall,
|
||||||
|
Invert: true,
|
||||||
|
Value: parsers.FunctionCall{
|
||||||
|
Type: parsers.FunctionCallIn,
|
||||||
|
Arguments: []interface{}{
|
||||||
|
parsers.SelectItem{
|
||||||
|
Path: []string{"c", "id"},
|
||||||
|
Type: parsers.SelectItemTypeField,
|
||||||
|
},
|
||||||
|
testutils.SelectItem_Constant_String("123"),
|
||||||
|
testutils.SelectItem_Constant_String("456"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Should parse IN function with function call", func(t *testing.T) {
|
t.Run("Should parse IN function with function call", func(t *testing.T) {
|
||||||
testQueryParse(
|
testQueryParse(
|
||||||
t,
|
t,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -425,7 +425,15 @@ MulDivExpression <- left:SelectItemWithParentheses operations:(ws op:MultiplyOrD
|
|||||||
return makeMathExpression(left, operations)
|
return makeMathExpression(left, operations)
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectItemWithParentheses <- "(" ws ex:OrExpression ws ")" { return ex, nil }
|
SelectItemWithParentheses <- inv:(Not ws)? "(" ws ex:OrExpression ws ")" {
|
||||||
|
if inv != nil {
|
||||||
|
if ex1, ok := ex.(parsers.SelectItem); ok {
|
||||||
|
ex1.Invert = true
|
||||||
|
return ex1, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ex, nil
|
||||||
|
}
|
||||||
/ inv:(Not ws)? ex:SelectItem {
|
/ inv:(Not ws)? ex:SelectItem {
|
||||||
if inv != nil {
|
if inv != nil {
|
||||||
ex1 := ex.(parsers.SelectItem)
|
ex1 := ex.(parsers.SelectItem)
|
||||||
|
|||||||
Reference in New Issue
Block a user