fix: quote openquery's server name via adapter.quote() instead of hand-formatted brackets - #816
Merged
axellpadilla merged 1 commit intoAug 7, 2026
Conversation
… hand-formatted brackets
sqlserver__openquery emitted OPENQUERY([{{ server_name }}], ...), a hand-
formatted bracket identifier that bypasses adapter.quote() and breaks the
one-quoting-style guard from #785 (test_macros_do_not_hand_format_identifiers).
Route it through adapter.quote() like every other macro-built identifier;
SQL Server accepts a double-quoted linked-server name under QUOTED_IDENTIFIER
ON (the adapter's default). Updates the functional test's compiled-SQL
assertions to match the new quoting.
axellpadilla
enabled auto-merge
August 6, 2026 23:56
axellpadilla
deleted the
fix/openquery-hand-formatted-identifier-quoting
branch
August 7, 2026 00:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR #790 landed
sqlserver__openqueryemittingOPENQUERY([{{ server_name }}], ...)— a hand-formatted bracket identifier. That trips the #785 guard (test_macros_do_not_hand_format_identifiers), which requires every macro-built identifier to go throughadapter.quote()so generated SQL keeps one quoting style, and broke CI on master right after merge:Fix
OPENQUERY([{{ server_name }}], ...)→OPENQUERY({{ adapter.quote(server_name) }}, ...). SQL Server accepts a double-quoted linked-server name underQUOTED_IDENTIFIER ON, the adapter's default.tests/functional/adapter/mssql/test_openquery.py's compiled-SQL assertions fromOPENQUERY([LOCALLOOP], ...)toOPENQUERY("LOCALLOOP", ...).Test plan
pytest tests/unit/adapters/mssql/test_quote.py— 60 passed, including the previously-failingtest_macros_do_not_hand_format_identifiers[openquery.sql]pytest tests/unit— 500 passedruff check dbt/ tests/— cleanpytest tests/functional/adapter/mssql/test_openquery.pyagainst a live local SQL Server (loopback linked server) — 9 passed