Bugfix: Fix wrong function name export and function name parsing (#2786)
This commit is contained in:
parent
d9fa31f745
commit
8b2ae9fc99
3 changed files with 17 additions and 8 deletions
|
@ -84,11 +84,6 @@ pub fn ident(i: &str) -> IResult<&str, Ident> {
|
||||||
Ok((i, Ident::from(v)))
|
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> {
|
pub fn multi(i: &str) -> IResult<&str, Ident> {
|
||||||
let (i, v) = recognize(separated_list1(tag("::"), take_while1(val_char)))(i)?;
|
let (i, v) = recognize(separated_list1(tag("::"), take_while1(val_char)))(i)?;
|
||||||
Ok((i, Ident::from(v)))
|
Ok((i, Ident::from(v)))
|
||||||
|
|
|
@ -71,7 +71,7 @@ impl DefineFunctionStatement {
|
||||||
|
|
||||||
impl fmt::Display for DefineFunctionStatement {
|
impl fmt::Display for DefineFunctionStatement {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
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() {
|
for (i, (name, kind)) in self.args.iter().enumerate() {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
f.write_str(", ")?;
|
f.write_str(", ")?;
|
||||||
|
|
|
@ -48,7 +48,8 @@ impl RemoveFunctionStatement {
|
||||||
|
|
||||||
impl Display for RemoveFunctionStatement {
|
impl Display for RemoveFunctionStatement {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
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, _) = tag_no_case("FUNCTION")(i)?;
|
||||||
let (i, _) = shouldbespace(i)?;
|
let (i, _) = shouldbespace(i)?;
|
||||||
let (i, _) = tag("fn::")(i)?;
|
let (i, _) = tag("fn::")(i)?;
|
||||||
let (i, name) = ident::plain(i)?;
|
let (i, name) = ident::multi(i)?;
|
||||||
let (i, _) = opt(|i| {
|
let (i, _) = opt(|i| {
|
||||||
let (i, _) = mightbespace(i)?;
|
let (i, _) = mightbespace(i)?;
|
||||||
let (i, _) = char('(')(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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue