From 11df879fc0e12b6ad615c6261d8f6119515278bc Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Sat, 22 May 2021 19:18:02 +0100 Subject: [PATCH] Ensure operator parsing works correctly --- src/sql/operator.rs | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/sql/operator.rs b/src/sql/operator.rs index f5927e84..c496d947 100644 --- a/src/sql/operator.rs +++ b/src/sql/operator.rs @@ -102,6 +102,25 @@ pub fn assigner(i: &str) -> IResult<&str, Operator> { pub fn operator(i: &str) -> IResult<&str, Operator> { alt(( + alt(( + map(tag("=="), |_| Operator::Exact), + map(tag("!="), |_| Operator::NotEqual), + map(tag("*="), |_| Operator::AllEqual), + map(tag("?="), |_| Operator::AnyEqual), + map(tag("="), |_| Operator::Equal), + )), + alt(( + map(tag("!~"), |_| Operator::NotLike), + map(tag("*~"), |_| Operator::AllLike), + map(tag("?~"), |_| Operator::AnyLike), + map(tag("~"), |_| Operator::Like), + )), + alt(( + map(tag("<="), |_| Operator::LessThanOrEqual), + map(tag("<"), |_| Operator::LessThan), + map(tag(">="), |_| Operator::MoreThanOrEqual), + map(tag(">"), |_| Operator::MoreThan), + )), alt(( map(tag("+"), |_| Operator::Add), map(tag("-"), |_| Operator::Sub), @@ -111,25 +130,6 @@ pub fn operator(i: &str) -> IResult<&str, Operator> { map(tag("/"), |_| Operator::Div), map(tag("÷"), |_| Operator::Div), )), - alt(( - map(tag("="), |_| Operator::Equal), - map(tag("=="), |_| Operator::Exact), - map(tag("!="), |_| Operator::NotEqual), - map(tag("*="), |_| Operator::AllEqual), - map(tag("?="), |_| Operator::AnyEqual), - )), - alt(( - map(tag("~"), |_| Operator::Like), - map(tag("!~"), |_| Operator::NotLike), - map(tag("*~"), |_| Operator::AllLike), - map(tag("?~"), |_| Operator::AnyLike), - )), - alt(( - map(tag("<="), |_| Operator::LessThanOrEqual), - map(tag("<"), |_| Operator::LessThan), - map(tag(">="), |_| Operator::MoreThanOrEqual), - map(tag(">"), |_| Operator::MoreThan), - )), alt(( map(tag("∋"), |_| Operator::Contain), map(tag("∌"), |_| Operator::NotContain), @@ -141,8 +141,6 @@ pub fn operator(i: &str) -> IResult<&str, Operator> { map(tag("⊆"), |_| Operator::AllInside), map(tag("⊂"), |_| Operator::SomeInside), map(tag("⊄"), |_| Operator::NoneInside), - map(tag("<•>"), |_| Operator::Inside), - map(tag("<|>"), |_| Operator::Intersects), )), alt(( map(tag_no_case("&&"), |_| Operator::And),