mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-16 04:00:15 +00:00
Support identifiers beginning with digits in MySQL (#856)
This commit is contained in:
parent
6b2b3f1f6c
commit
3e92ad349f
3 changed files with 115 additions and 3 deletions
|
@ -673,10 +673,10 @@ impl<'a> Tokenizer<'a> {
|
|||
return Ok(Some(Token::Period));
|
||||
}
|
||||
|
||||
let mut exponent_part = String::new();
|
||||
// Parse exponent as number
|
||||
if chars.peek() == Some(&'e') || chars.peek() == Some(&'E') {
|
||||
let mut char_clone = chars.peekable.clone();
|
||||
let mut exponent_part = String::new();
|
||||
exponent_part.push(char_clone.next().unwrap());
|
||||
|
||||
// Optional sign
|
||||
|
@ -703,6 +703,18 @@ impl<'a> Tokenizer<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// mysql dialect supports identifiers that start with a numeric prefix,
|
||||
// as long as they aren't an exponent number.
|
||||
if dialect_of!(self is MySqlDialect) && exponent_part.is_empty() {
|
||||
let word =
|
||||
peeking_take_while(chars, |ch| self.dialect.is_identifier_part(ch));
|
||||
|
||||
if !word.is_empty() {
|
||||
s += word.as_str();
|
||||
return Ok(Some(Token::make_word(s.as_str(), None)));
|
||||
}
|
||||
}
|
||||
|
||||
let long = if chars.peek() == Some(&'L') {
|
||||
chars.next();
|
||||
true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue