Skip to content

Commit 8bdc77d

Browse files
committed
Define identifier quote style for SQL Server
- this is required to have common tests with identifiers with that quote style
1 parent 38c8a17 commit 8bdc77d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/dialect/mssql.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ impl Dialect for MsSqlDialect {
5252
|| ch == '_'
5353
}
5454

55+
fn identifier_quote_style(&self, _identifier: &str) -> Option<char> {
56+
Some('[')
57+
}
58+
5559
/// SQL Server has `CONVERT(type, value)` instead of `CONVERT(value, type)`
5660
/// <https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16>
5761
fn convert_type_before_value(&self) -> bool {

tests/sqlparser_common.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9331,6 +9331,9 @@ fn parse_grant() {
93319331
verified_stmt("GRANT USAGE ON WAREHOUSE wh1 TO ROLE role1");
93329332
verified_stmt("GRANT OWNERSHIP ON INTEGRATION int1 TO ROLE role1");
93339333
verified_stmt("GRANT SELECT ON VIEW view1 TO ROLE role1");
9334+
9335+
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
9336+
.verified_stmt("GRANT SELECT ON [my_table] TO [public]");
93349337
}
93359338

93369339
#[test]
@@ -9355,6 +9358,9 @@ fn parse_deny() {
93559358

93569359
verified_stmt("DENY SELECT, INSERT, UPDATE, DELETE ON db1.sc1 TO role1, role2");
93579360
verified_stmt("DENY ALL ON db1.sc1 TO role1");
9361+
9362+
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
9363+
.verified_stmt("DENY SELECT ON [my_table] TO [public]");
93589364
}
93599365

93609366
#[test]

0 commit comments

Comments
 (0)