Fix T-SQL bracket-quoted identifiers producing mangled labels - #2723
Fix T-SQL bracket-quoted identifiers producing mangled labels#2723ayushcodes10 wants to merge 1 commit into
Conversation
tree-sitter-sql has no grammar token for T-SQL [bracket] quoting: each bracket lands as its own ERROR node, one byte short of the real pair, so [dbo].[Alpha] reads back as the label `dbo].[Alpha` instead of dbo.Alpha. Rewrite bracket-quoted identifiers to backtick-quoted ones before parsing (a form the grammar already handles cleanly), then strip the synthetic backticks back out for display. Guards against misfiring on Postgres/MySQL array-type syntax (text[], numeric(10)[3]). Fixes Graphify-Labs#2712.
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
This PR adds T-SQL bracket-identifier handling to the SQL extractor in graphify/extractors/sql.py. It introduces two helpers — _debracket_tsql, which rewrites [bracket]-quoted identifiers into backtick-quoted ones before parsing (skipping strings/comments and array-type syntax), and _strip_backtick_parts, which strips that synthetic quoting back out for display labels — plus wiring in extract_sql (a debracketed flag, _clean_name/_ident wrappers) so object references and names are read through the cleaning path. The extractor is only debracketed when the source contains no existing backtick. The test file tests/test_multilang.py adds several new SQL tests covering clean bracket labels, foreign-key reference resolution by clean name, and array-type non-corruption. The changed-symbols list also references many other multilang tests (Go, Rust, TS) and rationale entries, though the shown diff centers on SQL extraction and its new tests.
No blocking issues surfaced. 5 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 269 functions depend on the 115 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract_sql()— 12 callers, 9 callees - worse:
walk()— 1 callers, 9 callees
Verification — 269 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 126 function(s) in the blast radius were not formally verified this run
Formal verification
Could not verify: Could not verify extract\_sql.
The verifier did not have enough to check extract\_sql, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set
· 1 grounded finding(s) anchored inline below; 1 more finding(s) on lines outside this diff (see the check run).
tree-sitter-sql has no grammar token for T-SQL [bracket] quoting: each bracket lands as its own ERROR node, one byte short of the real pair, so [dbo].[Alpha] reads back as the label
dbo].[Alphainstead of dbo.Alpha. Rewrite bracket-quoted identifiers to backtick-quoted ones before parsing (a form the grammar already handles cleanly), then strip the synthetic backticks back out for display. Guards against misfiring on Postgres/MySQL array-type syntax (text[], numeric(10)[3]).Fixes #2712.