Commit a31fb1f
fix: escape ] in get_view_definition_sql via quotename
Address PR review feedback on get_view_definition_sql:
- Build the object name with quotename(schema) + '.' + quotename(identifier)
instead of manual [..].[..] bracketing. quotename() doubles embedded ]
characters, so legal identifiers containing ] no longer produce a malformed
object name (which OBJECT_ID would resolve to NULL).
- Add a focused functional test (runs under both CI collations, CS_AS and
CI_AS) covering an identifier that contains ] and the zero-row behavior for
a missing view that the view materialization's diff-skip relies on.
OBJECT_ID resolution still follows database collation rules. In the view
materialization, get_view_definition_sql is only ever called on the cached
existing_relation, whose casing comes straight from the catalog, so the
lookup casing always matches the stored object even under CS_AS.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ba27fef commit a31fb1f
2 files changed
Lines changed: 60 additions & 2 deletions
File tree
- dbt/include/sqlserver/macros/adapters
- tests/functional/adapter/mssql
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
95 | 96 | | |
96 | | - | |
97 | | - | |
| 97 | + | |
| 98 | + | |
98 | 99 | | |
99 | 100 | | |
100 | 101 | | |
| |||
Lines changed: 57 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments