Skip to content

T-SQL: a bracket-quoted CREATE PROCEDURE / CREATE FUNCTION name yields no node at all (0 of 845 procedures on a real dump) #2718

Open

Description

@YNFM

graphify 0.9.39, Windows, Python 3.14.2, graphify . --code-only (AST only, no backend).

A CREATE PROCEDURE or CREATE FUNCTION whose name is bracket-quoted produces no node at all. Not a mangled node, not a partial one — the callable is simply absent from graph.json, and the build exits 0.

Bracket quoting is what SSMS emits by default when scripting a database, so for T-SQL scripted out of SQL Server this is the normal case rather than an edge case.

Repro

schema.sql, bracketed:

CREATE TABLE dbo.Customer (Id INT NOT NULL PRIMARY KEY);
GO
CREATE PROCEDURE [dbo].[GetCustomer] @Id INT
AS
BEGIN
    SELECT Id FROM dbo.Customer WHERE Id = @Id;
END
GO
graphify . --code-only

Actual — 2 nodes: schema.sql, dbo.Customer. No GetCustomer.
Expected — a node for the procedure, as the bare-name form produces.

Change only the name to dbo.GetCustomer and it appears:

3 nodes : schema.sql, dbo.Customer, dbo.GetCustomer()

Isolation

Each row differs from its neighbours in one thing only:

input result
CREATE PROCEDURE [dbo].[GetCustomer] absent
CREATE PROCEDURE [GetCustomer] (no schema) absent
CREATE PROCEDURE dbo.GetCustomer present
bare name, body fully bracketed (FROM [dbo].[Customer] WHERE [Id] = @Id) present
bracketed name, no GO separators anywhere absent
CREATE FUNCTION [dbo].[CustomerName] absent
CREATE TABLE [dbo].[Customer] present (label dbo].[Customer — that is #2712)
CREATE VIEW [dbo].[CustomerList] present (label mangled the same way)

So it is the bracket quoting on the callable's own name, and nothing else:

Relationship to the existing SQL issues

Distinct from both:

Why it is worth prioritising

Measured on a ~10 MB SSMS-scripted T-SQL schema dump (~235 000 lines), built twice — verbatim, and again with bracket quoting stripped from plain identifiers only:

verbatim unbracketed
nodes 132 1 008
procedures present 0 / 845 845 / 845
functions present 5 / 16 16 / 16
tables present 45 / 431 57 / 431
views present 32 / 84 41 / 84

Two smaller dumps behave the same way (33 → 107 and 22 → 61 nodes, both 0 procedures → all procedures).

Being straight about one row: the 5 / 16 functions in the verbatim column are not explained by this issue — the minimal repro drops a bracketed function outright, so whatever lets those five through is something I did not isolate. Everything else in the table matches the repro.

The failure is silent — no warning, exit 0, a plausible node count and a healthy EXTRACTED percentage — so a graph of a stored-procedure-heavy database looks complete while containing none of its procedures. There is also no in-repo workaround: stripping brackets from committed SQL to satisfy the extractor would corrupt the source.

Note that the tables/views columns above improve only modestly, so this defect does not explain the low table yield on large dumps — that looks like something separate and is not what this issue is about.

Activity

  1. YNFM commented on Aug 13, 2026

    @YNFM
    Author

    Correction to my own report: there is a second, independent trigger for the same symptom, and my repro missed it.

    Running this against a real T-SQL repository — 94 .sql, 23 procedures, all absent from the graph — I expected bracket quoting to account for all 23. It does not. Seven of those procedures are declared with bare names and are still missing. What they share with the other sixteen is CREATE OR ALTER.

    Repro

    Same shape as the original, four variants, one difference each:

    declaration result
    CREATE PROCEDURE dbo.GetCustomer present
    CREATE OR ALTER PROCEDURE dbo.GetCustomer absent
    CREATE OR ALTER PROCEDURE [dbo].[GetCustomer] absent
    CREATE OR ALTER FUNCTION dbo.CustomerName present
    CREATE TABLE dbo.Customer (Id INT NOT NULL PRIMARY KEY);
    GO
    CREATE OR ALTER PROCEDURE dbo.GetCustomer @Id INT
    AS
    BEGIN
        SELECT Id FROM dbo.Customer WHERE Id = @Id;
    END
    GO

    → 2 nodes: schema.sql, dbo.Customer. Drop the OR ALTER and dbo.GetCustomer() appears.

    So OR ALTER breaks PROCEDURE but not FUNCTION, and it is independent of the bracket quoting in the original report — either one alone is sufficient to lose the node, which is why a corpus can lose 100% of its procedures to what looks like one cause.

    CREATE OR ALTER is the idiomatic form for a re-runnable migration script, so in practice this may be the more common of the two triggers.

    Why it matters for the fix

    Fixing bracket handling alone would have left that repository at 0 of 23 procedures — the same number it has today — because both triggers are present. Anyone verifying a fix against real SSMS-scripted or migration-style T-SQL needs both cases covered or the result will look unchanged.

    Happy to split this into its own issue if you would rather track it separately — it is the same symptom and the same declaration class, so I have kept it here rather than fragmenting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions