diff --git a/lib/src/sql/ident.rs b/lib/src/sql/ident.rs index d9a43863..7cba8789 100644 --- a/lib/src/sql/ident.rs +++ b/lib/src/sql/ident.rs @@ -84,11 +84,6 @@ pub fn ident(i: &str) -> IResult<&str, Ident> { Ok((i, Ident::from(v))) } -pub fn plain(i: &str) -> IResult<&str, Ident> { - let (i, v) = take_while1(val_char)(i)?; - Ok((i, Ident::from(v))) -} - pub fn multi(i: &str) -> IResult<&str, Ident> { let (i, v) = recognize(separated_list1(tag("::"), take_while1(val_char)))(i)?; Ok((i, Ident::from(v))) diff --git a/lib/src/sql/statements/define/function.rs b/lib/src/sql/statements/define/function.rs index 9941b3e5..a439dcc9 100644 --- a/lib/src/sql/statements/define/function.rs +++ b/lib/src/sql/statements/define/function.rs @@ -71,7 +71,7 @@ impl DefineFunctionStatement { impl fmt::Display for DefineFunctionStatement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "DEFINE FUNCTION fn::{}(", self.name)?; + write!(f, "DEFINE FUNCTION fn::{}(", self.name.0)?; for (i, (name, kind)) in self.args.iter().enumerate() { if i > 0 { f.write_str(", ")?; diff --git a/lib/src/sql/statements/remove/function.rs b/lib/src/sql/statements/remove/function.rs index 367bd8dc..1487912a 100644 --- a/lib/src/sql/statements/remove/function.rs +++ b/lib/src/sql/statements/remove/function.rs @@ -48,7 +48,8 @@ impl RemoveFunctionStatement { impl Display for RemoveFunctionStatement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "REMOVE FUNCTION fn::{}", self.name) + // Bypass ident display since we don't want backticks arround the ident. + write!(f, "REMOVE FUNCTION fn::{}", self.name.0) } } @@ -56,7 +57,7 @@ pub fn function(i: &str) -> IResult<&str, RemoveFunctionStatement> { let (i, _) = tag_no_case("FUNCTION")(i)?; let (i, _) = shouldbespace(i)?; let (i, _) = tag("fn::")(i)?; - let (i, name) = ident::plain(i)?; + let (i, name) = ident::multi(i)?; let (i, _) = opt(|i| { let (i, _) = mightbespace(i)?; let (i, _) = char('(')(i)?; @@ -71,3 +72,16 @@ pub fn function(i: &str) -> IResult<&str, RemoveFunctionStatement> { }, )) } + +#[cfg(test)] +mod test { + use super::super::remove; + + #[test] + fn remove_long_function() { + let sql = "REMOVE FUNCTION fn::foo::bar::baz::bac"; + let res = remove(sql); + let out = res.unwrap().1; + assert_eq!("REMOVE FUNCTION fn::foo::bar::baz::bac", format!("{}", out)) + } +}