Ensure <cast> functions only operate on a single expression

This commit is contained in:
Tobie Morgan Hitchcock 2021-05-22 19:21:59 +01:00
parent a67bbace36
commit 203b85e6d2
2 changed files with 4 additions and 4 deletions

View file

@ -111,7 +111,7 @@ pub fn expression(i: &str) -> IResult<&str, Expression> {
alt((binary, single))(i)
}
fn binary(i: &str) -> IResult<&str, Expression> {
pub fn binary(i: &str) -> IResult<&str, Expression> {
let (i, l) = literal(i)?;
let (i, _) = mightbespace(i)?;
let (i, o) = operator(i)?;
@ -120,7 +120,7 @@ fn binary(i: &str) -> IResult<&str, Expression> {
Ok((i, Expression::Binary(Box::new(l), o, Box::new(r))))
}
fn single(i: &str) -> IResult<&str, Expression> {
pub fn single(i: &str) -> IResult<&str, Expression> {
let (i, l) = literal(i)?;
Ok((i, Expression::Single(Box::new(l))))
}

View file

@ -6,7 +6,7 @@ use crate::err::Error;
use crate::fnc;
use crate::sql::comment::mightbespace;
use crate::sql::common::commas;
use crate::sql::expression::{expression, Expression};
use crate::sql::expression::{expression, single, Expression};
use crate::sql::literal::Literal;
use nom::branch::alt;
use nom::bytes::complete::tag;
@ -95,7 +95,7 @@ fn casts(i: &str) -> IResult<&str, Function> {
let (i, s) = function_casts(i)?;
let (i, _) = tag(">")(i)?;
let (i, _) = mightbespace(i)?;
let (i, v) = expression(i)?;
let (i, v) = single(i)?;
Ok((i, Function::Cast(s.to_string(), v)))
}