From eaedfbbb7c11d94d1564ac89075d45b6ea8e7857 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 18 Jul 2022 22:10:00 +0100 Subject: [PATCH] Add ability to use binary expressions in SQL SELECT statements --- lib/src/sql/value/value.rs | 91 +++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index 4a97e206..aa415a0a 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -1235,52 +1235,61 @@ pub fn double(i: &str) -> IResult<&str, Value> { pub fn single(i: &str) -> IResult<&str, Value> { alt(( - map(tag_no_case("NONE"), |_| Value::None), - map(tag_no_case("VOID"), |_| Value::Void), - map(tag_no_case("NULL"), |_| Value::Null), - map(tag_no_case("true"), |_| Value::True), - map(tag_no_case("false"), |_| Value::False), - map(subquery, Value::from), - map(function, Value::from), - map(datetime, Value::from), - map(duration, Value::from), - map(geometry, Value::from), - map(unique, Value::from), - map(number, Value::from), - map(object, Value::from), - map(array, Value::from), - map(param, Value::from), - map(regex, Value::from), - map(model, Value::from), - map(idiom, Value::from), - map(thing, Value::from), - map(strand, Value::from), + alt(( + map(tag_no_case("NONE"), |_| Value::None), + map(tag_no_case("VOID"), |_| Value::Void), + map(tag_no_case("NULL"), |_| Value::Null), + map(tag_no_case("true"), |_| Value::True), + map(tag_no_case("false"), |_| Value::False), + )), + alt(( + map(subquery, Value::from), + map(function, Value::from), + map(datetime, Value::from), + map(duration, Value::from), + map(geometry, Value::from), + map(unique, Value::from), + map(number, Value::from), + map(object, Value::from), + map(array, Value::from), + map(param, Value::from), + map(regex, Value::from), + map(model, Value::from), + map(idiom, Value::from), + map(thing, Value::from), + map(strand, Value::from), + )), ))(i) } pub fn select(i: &str) -> IResult<&str, Value> { alt(( - map(tag_no_case("NONE"), |_| Value::None), - map(tag_no_case("VOID"), |_| Value::Void), - map(tag_no_case("NULL"), |_| Value::Null), - map(tag_no_case("true"), |_| Value::True), - map(tag_no_case("false"), |_| Value::False), - map(subquery, Value::from), - map(function, Value::from), - map(datetime, Value::from), - map(duration, Value::from), - map(geometry, Value::from), - map(unique, Value::from), - map(number, Value::from), - map(object, Value::from), - map(array, Value::from), - map(param, Value::from), - map(regex, Value::from), - map(model, Value::from), - map(edges, Value::from), - map(thing, Value::from), - map(table, Value::from), - map(strand, Value::from), + alt(( + map(tag_no_case("NONE"), |_| Value::None), + map(tag_no_case("VOID"), |_| Value::Void), + map(tag_no_case("NULL"), |_| Value::Null), + map(tag_no_case("true"), |_| Value::True), + map(tag_no_case("false"), |_| Value::False), + )), + alt(( + map(expression, Value::from), + map(subquery, Value::from), + map(function, Value::from), + map(datetime, Value::from), + map(duration, Value::from), + map(geometry, Value::from), + map(unique, Value::from), + map(number, Value::from), + map(object, Value::from), + map(array, Value::from), + map(param, Value::from), + map(regex, Value::from), + map(model, Value::from), + map(edges, Value::from), + map(thing, Value::from), + map(table, Value::from), + map(strand, Value::from), + )), ))(i) }