Skip to content

Commit 0eaee16

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 87b9e03 commit 0eaee16

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
@@ -51,6 +51,10 @@ impl Dialect for MsSqlDialect {
5151
|| ch == '_'
5252
}
5353

54+
fn identifier_quote_style(&self, _identifier: &str) -> Option<char> {
55+
Some('[')
56+
}
57+
5458
/// SQL Server has `CONVERT(type, value)` instead of `CONVERT(value, type)`
5559
/// <https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16>
5660
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
@@ -9323,6 +9323,9 @@ fn parse_grant() {
93239323
verified_stmt("GRANT USAGE ON WAREHOUSE wh1 TO ROLE role1");
93249324
verified_stmt("GRANT OWNERSHIP ON INTEGRATION int1 TO ROLE role1");
93259325
verified_stmt("GRANT SELECT ON VIEW view1 TO ROLE role1");
9326+
9327+
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
9328+
.verified_stmt("GRANT SELECT ON [my_table] TO [public]");
93269329
}
93279330

93289331
#[test]
@@ -9347,6 +9350,9 @@ fn parse_deny() {
93479350

93489351
verified_stmt("DENY SELECT, INSERT, UPDATE, DELETE ON db1.sc1 TO role1, role2");
93499352
verified_stmt("DENY ALL ON db1.sc1 TO role1");
9353+
9354+
all_dialects_where(|d| d.identifier_quote_style("none") == Some('['))
9355+
.verified_stmt("DENY SELECT ON [my_table] TO [public]");
93509356
}
93519357

93529358
#[test]

0 commit comments

Comments
 (0)