mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-18 05:00:16 +00:00
support create function definition with $$
(#755)
* support create function definition using '2700775' * fix warn
This commit is contained in:
parent
d420001c37
commit
6c545195e1
5 changed files with 91 additions and 10 deletions
|
@ -145,6 +145,8 @@ pub enum Token {
|
|||
PGCubeRoot,
|
||||
/// `?` or `$` , a prepared statement arg placeholder
|
||||
Placeholder(String),
|
||||
/// `$$`, used for PostgreSQL create function definition
|
||||
DoubleDollarQuoting,
|
||||
/// ->, used as a operator to extract json field in PostgreSQL
|
||||
Arrow,
|
||||
/// ->>, used as a operator to extract json field as text in PostgreSQL
|
||||
|
@ -215,6 +217,7 @@ impl fmt::Display for Token {
|
|||
Token::LongArrow => write!(f, "->>"),
|
||||
Token::HashArrow => write!(f, "#>"),
|
||||
Token::HashLongArrow => write!(f, "#>>"),
|
||||
Token::DoubleDollarQuoting => write!(f, "$$"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -770,8 +773,14 @@ impl<'a> Tokenizer<'a> {
|
|||
}
|
||||
'$' => {
|
||||
chars.next();
|
||||
let s = peeking_take_while(chars, |ch| ch.is_alphanumeric() || ch == '_');
|
||||
Ok(Some(Token::Placeholder(String::from("$") + &s)))
|
||||
match chars.peek() {
|
||||
Some('$') => self.consume_and_return(chars, Token::DoubleDollarQuoting),
|
||||
_ => {
|
||||
let s =
|
||||
peeking_take_while(chars, |ch| ch.is_alphanumeric() || ch == '_');
|
||||
Ok(Some(Token::Placeholder(String::from("$") + &s)))
|
||||
}
|
||||
}
|
||||
}
|
||||
//whitespace check (including unicode chars) should be last as it covers some of the chars above
|
||||
ch if ch.is_whitespace() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue