From 0c3a5d02cab9c36fc1be9217adf32729334a6fa2 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 13 Jun 2019 12:04:04 -0700 Subject: [PATCH] Fixes --- internal/server/token.go | 14 ++------------ tests/testcmd_test.go | 9 +++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/server/token.go b/internal/server/token.go index 5b8c26a5..d1397fe6 100644 --- a/internal/server/token.go +++ b/internal/server/token.go @@ -724,10 +724,10 @@ loop: newExpr := &areaExpression{negate: negate, op: NOOP} negate = false if ae != nil { - ps.push(ae) ae.children = append(ae.children, newExpr) } ae = newExpr + ps.push(ae) vsout = nvs case tokenRParen: if negate { @@ -788,14 +788,7 @@ loop: err = errInvalidNumberOfArguments return } else { - parent, empty := ps.pop() - if empty { - parent = ae - } - parent.children = append( - parent.children, - &areaExpression{op: OR}) - ps.push(parent) + ae = &areaExpression{op: OR, children: []*areaExpression{ae}} } case NOOP: ae.op = OR @@ -826,8 +819,5 @@ loop: break loop } } - if prevExpr, empty := ps.pop(); !empty { - ae = prevExpr - } return } diff --git a/tests/testcmd_test.go b/tests/testcmd_test.go index 0a5ba0a1..9cb833b0 100644 --- a/tests/testcmd_test.go +++ b/tests/testcmd_test.go @@ -149,6 +149,15 @@ func testcmd_expression_test(mc *mockServer) error { {"TEST", "OBJECT", poly9, "INTERSECTS", "GET", "mykey", "poly8", "AND", "(", "OBJECT", poly, "AND", "NOT", "GET", "mykey", "line3", ")"}, {"1"}, {"TEST", "OBJECT", poly9, "INTERSECTS", "NOT", "GET", "mykey", "line3"}, {"1"}, + {"TEST", "NOT", "OBJECT", poly9, "INTERSECTS", "GET", "mykey", "line3"}, {"1"}, + {"TEST", "OBJECT", poly9, "INTERSECTS", "GET", "mykey", "line3", + "OR", "OBJECT", poly8, "AND", "OBJECT", poly}, {"1"}, + {"TEST", "OBJECT", poly9, "INTERSECTS", "OBJECT", poly8, "AND", "OBJECT", poly, + "OR", "GET", "mykey", "line3"}, {"1"}, + {"TEST", "OBJECT", poly9, "INTERSECTS", "GET", "mykey", "line3", "OR", + "(", "OBJECT", poly8, "AND", "OBJECT", poly, ")"}, {"1"}, + {"TEST", "OBJECT", poly9, "INTERSECTS", + "(", "GET", "mykey", "line3", "OR", "OBJECT", poly8, ")", "AND", "OBJECT", poly}, {"1"}, {"TEST", "OBJECT", poly9, "WITHIN", "OBJECT", poly8, "OR", "OBJECT", poly}, {"1"}, {"TEST", "OBJECT", poly9, "WITHIN", "OBJECT", poly8, "AND", "OBJECT", poly}, {"1"},