diff --git a/lib/src/sql/function.rs b/lib/src/sql/function.rs index 37545fc8..177d0d29 100644 --- a/lib/src/sql/function.rs +++ b/lib/src/sql/function.rs @@ -18,7 +18,9 @@ use nom::branch::alt; use nom::bytes::complete::tag; use nom::bytes::complete::take_while1; use nom::character::complete::char; +use nom::combinator::recognize; use nom::multi::separated_list0; +use nom::multi::separated_list1; use serde::ser::SerializeTupleVariant; use serde::{Deserialize, Serialize}; use std::cmp::Ordering; @@ -277,7 +279,8 @@ pub fn normal(i: &str) -> IResult<&str, Function> { pub fn custom(i: &str) -> IResult<&str, Function> { let (i, _) = tag("fn::")(i)?; - let (i, s) = take_while1(val_char)(i)?; + let (i, s) = recognize(separated_list1(tag("::"), take_while1(val_char)))(i)?; + let (i, _) = mightbespace(i)?; let (i, _) = char('(')(i)?; let (i, _) = mightbespace(i)?; let (i, a) = separated_list0(commas, value)(i)?; diff --git a/lib/src/sql/ident.rs b/lib/src/sql/ident.rs index c06522ff..4f4c9c9c 100644 --- a/lib/src/sql/ident.rs +++ b/lib/src/sql/ident.rs @@ -4,9 +4,12 @@ use crate::sql::escape::escape_ident; use nom::branch::alt; use nom::bytes::complete::escaped_transform; use nom::bytes::complete::is_not; +use nom::bytes::complete::tag; use nom::bytes::complete::take_while1; use nom::character::complete::char; +use nom::combinator::recognize; use nom::combinator::value; +use nom::multi::separated_list1; use nom::sequence::delimited; use serde::{Deserialize, Serialize}; use std::fmt::{self, Display, Formatter}; @@ -65,7 +68,12 @@ pub fn ident(i: &str) -> IResult<&str, Ident> { } pub fn plain(i: &str) -> IResult<&str, Ident> { - let (i, v) = ident_default(i)?; + 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.rs b/lib/src/sql/statements/define.rs index 9ba02c1b..2a978259 100644 --- a/lib/src/sql/statements/define.rs +++ b/lib/src/sql/statements/define.rs @@ -277,7 +277,7 @@ fn function(i: &str) -> IResult<&str, DefineFunctionStatement> { 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, _) = mightbespace(i)?; let (i, _) = char('(')(i)?; let (i, _) = mightbespace(i)?;