Add ability to use binary expressions in SQL SELECT statements

This commit is contained in:
Tobie Morgan Hitchcock 2022-07-18 22:10:00 +01:00
parent 548520662d
commit eaedfbbb7c

View file

@ -1234,12 +1234,15 @@ pub fn double(i: &str) -> IResult<&str, Value> {
} }
pub fn single(i: &str) -> IResult<&str, Value> { pub fn single(i: &str) -> IResult<&str, Value> {
alt((
alt(( alt((
map(tag_no_case("NONE"), |_| Value::None), map(tag_no_case("NONE"), |_| Value::None),
map(tag_no_case("VOID"), |_| Value::Void), map(tag_no_case("VOID"), |_| Value::Void),
map(tag_no_case("NULL"), |_| Value::Null), map(tag_no_case("NULL"), |_| Value::Null),
map(tag_no_case("true"), |_| Value::True), map(tag_no_case("true"), |_| Value::True),
map(tag_no_case("false"), |_| Value::False), map(tag_no_case("false"), |_| Value::False),
)),
alt((
map(subquery, Value::from), map(subquery, Value::from),
map(function, Value::from), map(function, Value::from),
map(datetime, Value::from), map(datetime, Value::from),
@ -1255,16 +1258,21 @@ pub fn single(i: &str) -> IResult<&str, Value> {
map(idiom, Value::from), map(idiom, Value::from),
map(thing, Value::from), map(thing, Value::from),
map(strand, Value::from), map(strand, Value::from),
)),
))(i) ))(i)
} }
pub fn select(i: &str) -> IResult<&str, Value> { pub fn select(i: &str) -> IResult<&str, Value> {
alt((
alt(( alt((
map(tag_no_case("NONE"), |_| Value::None), map(tag_no_case("NONE"), |_| Value::None),
map(tag_no_case("VOID"), |_| Value::Void), map(tag_no_case("VOID"), |_| Value::Void),
map(tag_no_case("NULL"), |_| Value::Null), map(tag_no_case("NULL"), |_| Value::Null),
map(tag_no_case("true"), |_| Value::True), map(tag_no_case("true"), |_| Value::True),
map(tag_no_case("false"), |_| Value::False), map(tag_no_case("false"), |_| Value::False),
)),
alt((
map(expression, Value::from),
map(subquery, Value::from), map(subquery, Value::from),
map(function, Value::from), map(function, Value::from),
map(datetime, Value::from), map(datetime, Value::from),
@ -1281,6 +1289,7 @@ pub fn select(i: &str) -> IResult<&str, Value> {
map(thing, Value::from), map(thing, Value::from),
map(table, Value::from), map(table, Value::from),
map(strand, Value::from), map(strand, Value::from),
)),
))(i) ))(i)
} }