Skip to content

Commit c03a7d7

Browse files
committed
Added unquoted identifiers unicode support for mySql, postgreSqp, also added a test for that
1 parent bc2c4e2 commit c03a7d7

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

src/dialect/mysql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl Dialect for MySqlDialect {
5151
}
5252

5353
fn is_identifier_part(&self, ch: char) -> bool {
54-
self.is_identifier_start(ch) || ch.is_ascii_digit()
54+
self.is_identifier_start(ch) || ch.is_ascii_digit() || !ch.is_ascii()
5555
}
5656

5757
fn is_delimited_identifier_start(&self, ch: char) -> bool {

src/dialect/postgresql.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Dialect for PostgreSqlDialect {
7272
}
7373

7474
fn is_identifier_part(&self, ch: char) -> bool {
75-
ch.is_alphabetic() || ch.is_ascii_digit() || ch == '$' || ch == '_'
75+
ch.is_alphabetic() || ch.is_ascii_digit() || ch == '$' || ch == '_' || !ch.is_ascii()
7676
}
7777

7878
fn supports_unicode_string_literal(&self) -> bool {

src/dialect/redshift.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Dialect for RedshiftSqlDialect {
8888
fn is_identifier_part(&self, ch: char) -> bool {
8989
// Extends Postgres dialect with sharp and UTF-8 multibyte chars
9090
// https://docs.aws.amazon.com/redshift/latest/dg/r_names.html
91-
PostgreSqlDialect {}.is_identifier_part(ch) || ch == '#' || !ch.is_ascii()
91+
PostgreSqlDialect {}.is_identifier_part(ch) || ch == '#'
9292
}
9393

9494
/// redshift has `CONVERT(type, value)` instead of `CONVERT(value, type)`

tests/sqlparser_common.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16133,3 +16133,10 @@ SELECT * FROM tbl2
1613316133
assert_eq!(stmts.len(), 2);
1613416134
assert!(stmts.iter().all(|s| matches!(s, Statement::Query { .. })));
1613516135
}
16136+
#[test]
16137+
fn test_unicode_support() {
16138+
let unicode_sql = r#"SELECT phoneǤЖשचᎯ⻩☯♜🦄⚛🀄ᚠ⌛🌀 tbl FROM customers"#;
16139+
let dialects_supporting_unicode = TestedDialects::new(vec![Box::new(MySqlDialect {}), Box::new(RedshiftSqlDialect {}), Box::new(PostgreSqlDialect {})]);
16140+
let _ = dialects_supporting_unicode.parse_sql_statements(unicode_sql).unwrap();
16141+
}
16142+

0 commit comments

Comments
 (0)