Skip to content

Commit

Permalink
Non-Latin characters support (sqlparser-rs#840)
Browse files Browse the repository at this point in the history
* Non latin characters

---------

Co-authored-by: Maciej Skrzypkowski <maciej.skrzypkowski@satoricyber.com>

* Test for mysql

---------

Co-authored-by: Maciej Skrzypkowski <maciej.skrzypkowski@satoricyber.com>
  • Loading branch information
2 people authored and mobuchowski committed Aug 7, 2023
1 parent ceeeadf commit 439fd61
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
5 changes: 2 additions & 3 deletions src/dialect/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ pub struct GenericDialect;

impl Dialect for GenericDialect {
fn is_identifier_start(&self, ch: char) -> bool {
ch.is_ascii_lowercase() || ch.is_ascii_uppercase() || ch == '_' || ch == '#' || ch == '@'
ch.is_alphabetic() || ch == '_' || ch == '#' || ch == '@'
}

fn is_identifier_part(&self, ch: char) -> bool {
ch.is_ascii_lowercase()
|| ch.is_ascii_uppercase()
ch.is_alphabetic()
|| ch.is_ascii_digit()
|| ch == '@'
|| ch == '$'
Expand Down
6 changes: 2 additions & 4 deletions src/dialect/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ impl Dialect for MsSqlDialect {

fn is_identifier_start(&self, ch: char) -> bool {
// See https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers?view=sql-server-2017#rules-for-regular-identifiers
// We don't support non-latin "letters" currently.
ch.is_ascii_lowercase() || ch.is_ascii_uppercase() || ch == '_' || ch == '#' || ch == '@'
ch.is_alphabetic() || ch == '_' || ch == '#' || ch == '@'
}

fn is_identifier_part(&self, ch: char) -> bool {
ch.is_ascii_lowercase()
|| ch.is_ascii_uppercase()
ch.is_alphabetic()
|| ch.is_ascii_digit()
|| ch == '@'
|| ch == '$'
Expand Down
3 changes: 1 addition & 2 deletions src/dialect/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ impl Dialect for MySqlDialect {
// See https://dev.mysql.com/doc/refman/8.0/en/identifiers.html.
// We don't yet support identifiers beginning with numbers, as that
// makes it hard to distinguish numeric literals.
ch.is_ascii_lowercase()
|| ch.is_ascii_uppercase()
ch.is_alphabetic()
|| ch == '_'
|| ch == '$'
|| ch == '@'
Expand Down
8 changes: 2 additions & 6 deletions src/dialect/postgresql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ impl Dialect for PostgreSqlDialect {
// We don't yet support identifiers beginning with "letters with
// diacritical marks and non-Latin letters"
ch.is_ascii_lowercase() || ch.is_ascii_uppercase() || ch == '_' || ch == '$'
}
}

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

fn parse_statement(&self, parser: &mut Parser) -> Option<Result<Statement, ParserError>> {
Expand Down

0 comments on commit 439fd61

Please sign in to comment.