Metadata-Version: 2.4
Name: rbtr-lang-sql
Version: 2026.9.0.dev1
Summary: rbtr — SQL language plugin
Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,sql
Author: Alejandro Giacometti
Author-email: Alejandro Giacometti <alejandro.giacometti@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: SQL
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Text Processing :: Indexing
Classifier: Typing :: Typed
Requires-Dist: rbtr==2026.9.0.dev1
Requires-Dist: tree-sitter-sql
Requires-Python: >=3.13
Project-URL: Homepage, https://github.com/janrito/rbtr
Project-URL: Repository, https://github.com/janrito/rbtr
Project-URL: Documentation, https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-sql#readme
Project-URL: Issues, https://github.com/janrito/rbtr/issues
Project-URL: Changelog, https://github.com/janrito/rbtr/releases
Description-Content-Type: text/markdown

# rbtr-lang-sql

SQL support for [rbtr]. Optional plugin — install with
`pip install rbtr[sql]`.

[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme

## What it ingests

One chunk per top-level SQL statement (plus one per CTE). SQL has no
classes or functions in the object-oriented sense and no native import
mechanism, so statements map onto rbtr's capture conventions by shape:
structural definitions become classes, routines and executable
statements become functions, and standalone named objects become
variables.

- **Structural definitions** — `CREATE TABLE`, `CREATE VIEW` /
  `MATERIALIZED VIEW`, `CREATE TYPE ... AS ENUM` / composite types.
- **Routines & statements** — `CREATE FUNCTION`, `SELECT`, `INSERT`,
  `UPDATE`, `DELETE`, `WITH ... AS` (CTEs), `ALTER` / `DROP`.
- **Named objects** — `CREATE INDEX` / `SEQUENCE` / `SCHEMA` / `ROLE` /
  `TRIGGER`.

`CREATE PROCEDURE` and `PRAGMA` are not extracted — the generic grammar
has no node for them.

## Chunks produced

`name` is the statement's target object; `scope` is always empty (SQL
has no nesting). A statement with no nameable target (`SELECT 1`, a
`UNION`) carries no name.

```sql
CREATE TABLE users (id INT, name TEXT);   -- class    "users"
CREATE VIEW active AS SELECT * FROM users; -- class    "active"
CREATE TYPE mood AS ENUM ('sad','happy');  -- class    "mood"
CREATE FUNCTION add(a INT) ...             -- function "add"
SELECT id, name FROM users;                -- function "users"
INSERT INTO logs (msg) VALUES ('hi');      -- function "logs"
WITH ranked AS (...) SELECT ...            -- function "ranked" (per CTE)
CREATE INDEX idx_name ON users (name);     -- variable "idx_name"
CREATE SEQUENCE order_id START 1;          -- variable "order_id"
```

## Embedded / injected chunks

None. SQL does not embed other languages.

## Grammar & dependencies

Uses the `tree-sitter-sql` grammar (one generic grammar for all
dialects). No dependency on other language plugins.
