Skip to content

feat(sql): extend the table scanner with DDL verbs and the Access IN clause #256

Description

@ardelperal

Summary

sql-table-scan.ts — the shared scanner every SQL path in the project uses — captures table names after FROM, JOIN, INTO and UPDATE only.

Missing: CREATE TABLE, ALTER TABLE, DROP TABLE, and the Access-specific IN "otra.accdb" clause that points a query at an external database file. That last one is a cross-backend edge with no representation in the graph today.

Proposed fix

  1. Extend the clause set with the three DDL verbs, each carrying access: 'write'.

  2. Add the IN "<path>" clause as a distinct capture. The target is an external database file, not a table, so it gets its own representation — decided: emit a file-kind node for the external backend, keyed on the normalized path, with metadata: { external: true, backendPath }, and a references edge to it tagged synthesizedBy: 'vba-external-backend'.

    file is the honest kind: it is a file, just not one this index parsed. It needs no new NodeKind, and metadata.external keeps it distinguishable from indexed files in every query.

    This must agree with the linked-table origins in feat(vba): parameter nodes, and table fields from the Access ERD export #257 Half B, which represent the same thing from the Access structure export. Whichever issue lands first fixes the shape; the second adopts it.

  3. This module is shared by vba/sql-wrapper.ts, vba-form-extractor.ts and sql-query-extractor.ts. Every change is a change to all three.

Risk

This is the one module every SQL path shares, and its reserved-word reject list is the project's main defence against emitting WHERE as a table. Regression-test the reject list explicitly, not incidentally.

Acceptance criteria

  • CREATE TABLE TbNueva (...) -> write reference to TbNueva
  • DROP TABLE TbVieja -> write reference to TbVieja
  • SELECT * FROM T IN "C:\datos\otra.accdb" -> one external file node with external: true plus a vba-external-backend reference; T still resolves as a table
  • The same external path named from two different queries converges on one file node
  • Every existing reserved-word rejection still holds — re-run the full reject-list test suite
  • sqlTablesReferenced rises; no reserved word appears among the new names

Context

Task T15 of docs/vba-node-discovery-plan.md.

Activity

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

    area:vbaVBA/Access-specific work (parent codegraph product)status:approvedApproved for implementationtype:featureNew feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions