File tree Expand file tree Collapse file tree 4 files changed +18
-8
lines changed Expand file tree Collapse file tree 4 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,13 @@ impl Dialect for MySqlDialect {
43
43
// See https://dev.mysql.com/doc/refman/8.0/en/identifiers.html.
44
44
// Identifiers which begin with a digit are recognized while tokenizing numbers,
45
45
// so they can be distinguished from exponent numeric literals.
46
+ // MySQL also implements non ascii utf-8 charecters
46
47
ch. is_alphabetic ( )
47
48
|| ch == '_'
48
49
|| ch == '$'
49
50
|| ch == '@'
50
51
|| ( '\u{0080}' ..='\u{ffff}' ) . contains ( & ch)
52
+ || !ch. is_ascii ( )
51
53
}
52
54
53
55
fn is_identifier_part ( & self , ch : char ) -> bool {
Original file line number Diff line number Diff line change @@ -65,10 +65,9 @@ impl Dialect for PostgreSqlDialect {
65
65
}
66
66
67
67
fn is_identifier_start ( & self , ch : char ) -> bool {
68
- // See https://www.postgresql.org/docs/11/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS
69
- // We don't yet support identifiers beginning with "letters with
70
- // diacritical marks"
71
- ch. is_alphabetic ( ) || ch == '_'
68
+ ch. is_alphabetic ( ) || ch == '_' ||
69
+ // PostgreSQL implements Unicode characters in identifiers.
70
+ !ch. is_ascii ( )
72
71
}
73
72
74
73
fn is_identifier_part ( & self , ch : char ) -> bool {
Original file line number Diff line number Diff line change @@ -80,9 +80,9 @@ impl Dialect for RedshiftSqlDialect {
80
80
}
81
81
82
82
fn is_identifier_start ( & self , ch : char ) -> bool {
83
- // Extends Postgres dialect with sharp and UTF-8 multibyte chars
83
+ // UTF-8 multibyte characters are supported in identifiers via the PostgreSqlDialect.
84
84
// https://docs.aws.amazon.com/redshift/latest/dg/r_names.html
85
- PostgreSqlDialect { } . is_identifier_start ( ch) || ch == '#' || !ch . is_ascii ( )
85
+ PostgreSqlDialect { } . is_identifier_start ( ch) || ch == '#'
86
86
}
87
87
88
88
fn is_identifier_part ( & self , ch : char ) -> bool {
Original file line number Diff line number Diff line change @@ -11151,9 +11151,7 @@ fn parse_non_latin_identifiers() {
11151
11151
let supported_dialects = TestedDialects::new(vec![
11152
11152
Box::new(GenericDialect {}),
11153
11153
Box::new(DuckDbDialect {}),
11154
- Box::new(PostgreSqlDialect {}),
11155
11154
Box::new(MsSqlDialect {}),
11156
- Box::new(MySqlDialect {}),
11157
11155
]);
11158
11156
assert!(supported_dialects
11159
11157
.parse_sql_statements("SELECT 💝 FROM table1")
@@ -16147,3 +16145,14 @@ fn test_identifier_unicode_support() {
16147
16145
]);
16148
16146
let _ = dialects.verified_stmt(sql);
16149
16147
}
16148
+
16149
+ #[test]
16150
+ fn test_identifier_unicode_start() {
16151
+ let sql = r#"SELECT 💝phone AS 💝 FROM customers"#;
16152
+ let dialects = TestedDialects::new(vec![
16153
+ Box::new(MySqlDialect {}),
16154
+ Box::new(RedshiftSqlDialect {}),
16155
+ Box::new(PostgreSqlDialect {}),
16156
+ ]);
16157
+ let _ = dialects.verified_stmt(sql);
16158
+ }
You can’t perform that action at this time.
0 commit comments