Add regression test for T-SQL bracketed FK dropping child table - #2722
Add regression test for T-SQL bracketed FK dropping child table#2722ayushcodes10 wants to merge 2 commits 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.
A bracket-quoted FOREIGN KEY ... REFERENCES clause could confuse the parser badly enough that the whole child table (with its FK constraint) landed as bogus nested content inside the parent table's own subtree, dropping the child table from the graph and fabricating a self-referencing EXTRACTED edge on the parent. Already fixed as a side effect of the Graphify-Labs#2712 debracketing change on this branch; this adds coverage for the specific Graphify-Labs#2713 repro. Fixes Graphify-Labs#2713.
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 pull request adds T-SQL bracket-quoted identifier support to the SQL extractor. It introduces two helper functions (_debracket_tsql, which rewrites [bracket]-quoted identifiers to backtick-quoted ones before parsing to work around a tree-sitter-sql grammar gap, and _strip_backtick_parts, which undoes that substitution for display labels), and wires them into extract_sql via new _clean_name and _ident helpers applied wherever identifier/object_reference nodes are read. The change is gated so debracketing is skipped when source already contains a backtick, and includes handling for string literals, comments, and array-type syntax. The test file adds new cases covering bracket identifier labeling, cross-reference resolution, array-type non-corruption, and other scenarios; the accompanying symbol churn in the test module reflects these additions.
No blocking issues surfaced. 5 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 271 functions depend on the 117 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract_sql()— 13 callers, 9 callees - worse:
walk()— 1 callers, 9 callees
Verification — 271 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: 128 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).
|
@safishamsi this PR's CI run is waiting on approval (first-time contributor gate) — could you approve the workflow run when you get a chance? Happy to address any review feedback in the meantime. |
A bracket-quoted FOREIGN KEY ... REFERENCES clause could confuse the
parser badly enough that the whole child table (with its FK
constraint) landed as bogus nested content inside the parent table's
own subtree, dropping the child table from the graph and fabricating
a self-referencing EXTRACTED edge on the parent. Already fixed as a
side effect of the #2712 debracketing change; this adds coverage for
the specific #2713 repro.
Fixes #2713.