You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: SQL: CREATE TABLEs inside BEGIN; … COMMIT; still dropped when a DO $$ … END $$; block makes tree-sitter-sql emit a top-level block (follow-up to #2953) #3886
I have checked the Troubleshooting section in the README
What happened?
extract_sql silently drops every CREATE TABLE inside a BEGIN; … COMMIT; transaction when the transaction also contains a DO $$ … END $$; block.
tree-sitter-sql parses BEGIN; as the opener of a block that closes on the END of the DO body. The top-level node is then block instead of transaction. Since #2953, the top-level dispatch in graphify/extractors/sql.py walks statement, transaction, ERROR and a few Firebird types, but not block, so nothing inside it is extracted. The create_table nodes are still in the tree, under the block. No error or warning is printed.
Expected:users is extracted as a table node. Actual: only the file node is produced.
Real-world impact: on an 850-line PostgreSQL schema.sql (PL/pgSQL trigger functions plus a few idempotent DO $$ blocks), 8 of the 11 CREATE TABLE statements and all their triggers are missing from the graph.
Steps to reproduce
1. Save as `repro.sql`:
BEGIN;
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY
);
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_trigger WHERE tgname = 't') THEN
CREATE TRIGGER t BEFORE UPDATE ON users
FOR EACH ROW EXECUTE FUNCTION touch();
END IF;
END $$;
COMMIT;
2. Run in a fresh env:
uvx --from 'graphifyy[sql]==0.9.70' python -c "from pathlib import Pathfrom graphify.extract import extract_sqlprint([n['label'] for n in extract_sql(Path('repro.sql'))['nodes']])"
3. Control case: replace `BEGIN;` with `BEGIN TRANSACTION;` (equivalent in PostgreSQL) and run again. `users` is now extracted.
Error output or graph output
No traceback: the failure is silent.
# BEGIN;
['repro.sql']
# BEGIN TRANSACTION;
['repro.sql', 'users']
Top-level nodes of the tree-sitter-sql parse (type, start row, end row):
# BEGIN;
[('block', 1, 12), ('ERROR', 12, 12), ('ERROR', 13, 15)]
# BEGIN TRANSACTION;
[('transaction', 1, 15)]
Graphify version
0.9.70
Operating System
Linux
Python Version
3.12
Installation Method
uv tool install (recommended)
Additional Environment Details
tree-sitter-sql 0.3.11, py-tree-sitter 0.25.2
Also reproduced on graphifyy 0.9.53 (uv tool install 'graphifyy[sql]==0.9.53')
Reproduced on 0.9.70 in a clean throwaway env (uvx --from 'graphifyy[sql]==0.9.70'), not from a git checkout of v8
No provider environment variables set: this is AST-only extraction, no LLM involved
Activity
github-actions commentedon Sep 27, 2026
Thanks for opening this issue, @mininic1. 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.
fix(sql): walk block nodes so DDL before a DO block is extracted