Support identifiers beginning with digits in MySQL (#856)

This commit is contained in:
AviRaboah 2023-04-26 16:27:04 +03:00 committed by GitHub
parent 6b2b3f1f6c
commit 3e92ad349f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 115 additions and 3 deletions

View file

@ -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