Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unquoted identifiers naming rule is incorrect #1197

Open
jayzhan211 opened this issue Mar 29, 2024 · 0 comments
Open

Unquoted identifiers naming rule is incorrect #1197

jayzhan211 opened this issue Mar 29, 2024 · 0 comments

Comments

@jayzhan211
Copy link
Contributor

The naming rule is in https://dev.mysql.com/doc/refman/8.0/en/identifiers.html

The rule for unquoted identifiers is incorrect.

  • ASCII: [0-9,a-z,A-Z$_] (basic Latin letters, digits 0-9, dollar, underscore)
  • Extended: U+0080 .. U+FFFF

In the following test, we can see that @ is unpermitted

let sql = "SELECT 123col_$@123abc FROM \"table\"";

I think we need to fix the unquoted identifiers for MYSQL and HIVE

if dialect_of!(self is MySqlDialect | HiveDialect) && 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)));
}
}

MYSQL

fn is_identifier_start(&self, ch: char) -> bool {
// See https://dev.mysql.com/doc/refman/8.0/en/identifiers.html.
// Identifiers which begin with a digit are recognized while tokenizing numbers,
// so they can be distinguished from exponent numeric literals.
ch.is_alphabetic()
|| ch == '_'
|| ch == '$'
|| ch == '@'
|| ('\u{0080}'..='\u{ffff}').contains(&ch)
}
fn is_identifier_part(&self, ch: char) -> bool {
self.is_identifier_start(ch) || ch.is_ascii_digit()
}

HIVE

fn is_identifier_part(&self, ch: char) -> bool {
ch.is_ascii_lowercase()
|| ch.is_ascii_uppercase()
|| ch.is_ascii_digit()
|| ch == '_'
|| ch == '$'
|| ch == '{'
|| ch == '}'
}

@jayzhan211 jayzhan211 changed the title Unquoted identifiers name are incorrect Unquoted identifiers naming rule is incorrect Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant