mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-16 04:00:15 +00:00
Fix parse error on some prepared statement placeholders (#604)
sqlparser can now parse all the prepared statement placeholders supported by SQLite: - ? - ?NNN - @VVV - :VVV - $VVV See: https://www.sqlite.org/lang_expr.html#varparam This does not break existing support for postgresql's '@' operator Fixes #603
This commit is contained in:
parent
3ac1bb5b80
commit
604f755a59
4 changed files with 45 additions and 12 deletions
|
@ -678,13 +678,14 @@ impl<'a> Tokenizer<'a> {
|
|||
}
|
||||
}
|
||||
'@' => self.consume_and_return(chars, Token::AtSign),
|
||||
'?' => self.consume_and_return(chars, Token::Placeholder(String::from("?"))),
|
||||
'?' => {
|
||||
chars.next();
|
||||
let s = peeking_take_while(chars, |ch| ch.is_numeric());
|
||||
Ok(Some(Token::Placeholder(String::from("?") + &s)))
|
||||
}
|
||||
'$' => {
|
||||
chars.next();
|
||||
let s = peeking_take_while(
|
||||
chars,
|
||||
|ch| matches!(ch, '0'..='9' | 'A'..='Z' | 'a'..='z'),
|
||||
);
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue