SQL: tree-sitter-sql 0.3.13 drops writes from parsed T-SQL procedures
Summary
On clean graphify v0.9.106 with tree-sitter-sql 0.3.13, a DELETE inside a T-SQL procedure produces no writes_to edge. With tree-sitter-sql 0.3.11 the edge is present. The dependency is unpinned in the sql extra.
Reproduction
Install the dependencies from a clean v0.9.106 checkout with python -m pip install ".[sql]" "tree-sitter-sql==0.3.13", then run:
from pathlib import Path
from tempfile import TemporaryDirectory
from graphify.extract import extract_sql
with TemporaryDirectory() as tmp:
path = Path(tmp) / 'demo.sql'
path.write_text('CREATE PROCEDURE dbo.D AS\nBEGIN\n DELETE FROM dbo.Payments WHERE Amount = 0\nEND\nGO\n', encoding='utf-8')
graph = extract_sql(path)
nodes = {n['id']: n['label'] for n in graph['nodes']}
print(sorted((nodes[e['source']], e['relation'], nodes[e['target']]) for e in graph['edges'] if e['relation'] != 'contains'))
Observed: []. Expected: [('dbo.D()', 'writes_to', 'dbo.Payments')].
Related
#4635 covers writes from T-SQL procedures. The newer grammar parses this procedure structurally, so it no longer takes the recovery path.
Thanks for opening this issue, @sub4biz. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
Fixed by #5211 (e4773791), released in graphify 0.9.110. Thanks @sub4biz for the report and @sunhouy for the fix.