Skip to content

Commit

Permalink
Fix: properly escape closing identifier delimiters (#4202)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgesittas authored Oct 2, 2024
1 parent 0de59ce commit f935e42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 1 addition & 3 deletions sqlglot/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,9 +672,7 @@ def __init__(
self._escaped_quote_end: str = (
self.dialect.tokenizer_class.STRING_ESCAPES[0] + self.dialect.QUOTE_END
)
self._escaped_identifier_end: str = (
self.dialect.tokenizer_class.IDENTIFIER_ESCAPES[0] + self.dialect.IDENTIFIER_END
)
self._escaped_identifier_end = self.dialect.IDENTIFIER_END * 2

self._next_name = name_sequence("_t")

Expand Down
4 changes: 4 additions & 0 deletions tests/dialects/test_tsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def test_tsql(self):
self.validate_identity(
"COPY INTO test_1 FROM 'path' WITH (FORMAT_NAME = test, FILE_TYPE = 'CSV', CREDENTIAL = (IDENTITY='Shared Access Signature', SECRET='token'), FIELDTERMINATOR = ';', ROWTERMINATOR = '0X0A', ENCODING = 'UTF8', DATEFORMAT = 'ymd', MAXERRORS = 10, ERRORFILE = 'errorsfolder', IDENTITY_INSERT = 'ON')"
)
self.validate_identity(
'SELECT 1 AS "[x]"',
"SELECT 1 AS [[x]]]",
)
self.assertEqual(
annotate_types(self.validate_identity("SELECT 1 WHERE EXISTS(SELECT 1)")).sql("tsql"),
"SELECT 1 WHERE EXISTS(SELECT 1)",
Expand Down

0 comments on commit f935e42

Please sign in to comment.