Skip to content

Commit 8161b86

Browse files
authored
chore(mssql): always append semicolon to statement (#11732)
## Description of changes Terminate all MSSQL statements with a semicolon. This is required for some statements (e.g. [`MERGE`](#11624)). Raising a separate PR so that this broader change (not solely affecting `Backend.upsert()` implementation) is reflected in the changelog. All tests pass as-is.
1 parent 38b19c7 commit 8161b86

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ibis/backends/mssql/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ def _safe_raw_sql(self, query, *args, **kwargs):
424424
with contextlib.suppress(AttributeError):
425425
query = query.sql(self.dialect)
426426

427+
# Although the semicolon isn't required for most statements, the
428+
# T-SQL docs state that it will be required in a future version.
429+
# https://learn.microsoft.com/en-us/sql/t-sql/language-elements/transact-sql-syntax-conventions-transact-sql?view=sql-server-ver17&tabs=code
430+
if not query.rstrip().endswith(";"):
431+
query = f"{query};"
432+
427433
with self.begin() as cur:
428434
cur.execute(query, *args, **kwargs)
429435
yield cur

0 commit comments

Comments
 (0)