Skip to content

Commit a783766

Browse files
committed
SGA-11409 Added requested changes from pr request and fixed conflicts and codestyle issues
1 parent c03a7d7 commit a783766

4 files changed

Lines changed: 17 additions & 9 deletions

File tree

src/dialect/mysql.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ 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() || !ch.is_ascii()
54+
self.is_identifier_start(ch) || ch.is_ascii_digit() ||
55+
// MySQL implements Unicode characters in identifiers.
56+
!ch.is_ascii()
5557
}
5658

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

src/dialect/postgresql.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ 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 == '_' || !ch.is_ascii()
75+
ch.is_alphabetic() || ch.is_ascii_digit() || ch == '$' || ch == '_' ||
76+
// PostgreSQL implements Unicode characters in identifiers.
77+
!ch.is_ascii()
7678
}
7779

7880
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 == '#'
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: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16133,10 +16133,14 @@ 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-
}
1614216136

16137+
#[test]
16138+
fn test_identifier_unicode_support() {
16139+
let sql = r#"SELECT phoneǤЖשचᎯ⻩☯♜🦄⚛🀄ᚠ⌛🌀 AS tbl FROM customers"#;
16140+
let dialects = TestedDialects::new(vec![
16141+
Box::new(MySqlDialect {}),
16142+
Box::new(RedshiftSqlDialect {}),
16143+
Box::new(PostgreSqlDialect {}),
16144+
]);
16145+
let _ = dialects.verified_stmt(sql);
16146+
}

0 commit comments

Comments
 (0)