Skip to content

Commit 74352d5

Browse files
fix(tsql): use plus operator for string concat to support more systems that use tsql (#4067)
* fix(tsql): use plus operator for string concat to support more systems that use tsql * Style fixup --------- Co-authored-by: Jo <[email protected]>
1 parent 75cafad commit 74352d5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

sqlglot/dialects/tsql.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import datetime
44
import re
55
import typing as t
6-
from functools import partial
6+
from functools import partial, reduce
77

88
from sqlglot import exp, generator, parser, tokens, transforms
99
from sqlglot.dialects.dialect import (
@@ -1192,3 +1192,8 @@ def declareitem_sql(self, expression: exp.DeclareItem) -> str:
11921192
def options_modifier(self, expression: exp.Expression) -> str:
11931193
options = self.expressions(expression, key="options")
11941194
return f" OPTION{self.wrap(options)}" if options else ""
1195+
1196+
def dpipe_sql(self, expression: exp.DPipe) -> str:
1197+
return self.sql(
1198+
reduce(lambda x, y: exp.Add(this=x, expression=y), expression.flatten())
1199+
)

tests/dialects/test_tsql.py

+5
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ def test_tsql(self):
420420
"SELECT val FROM (VALUES ((TRUE), (FALSE), (NULL))) AS t(val)",
421421
write_sql="SELECT val FROM (VALUES ((1), (0), (NULL))) AS t(val)",
422422
)
423+
self.validate_identity("'a' + 'b'")
424+
self.validate_identity(
425+
"'a' || 'b'",
426+
"'a' + 'b'",
427+
)
423428

424429
def test_option(self):
425430
possible_options = [

0 commit comments

Comments
 (0)