rbtr-lang-sql 2026.9.0.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rbtr_lang_sql-2026.9.0.dev1/LICENSE +21 -0
- rbtr_lang_sql-2026.9.0.dev1/PKG-INFO +79 -0
- rbtr_lang_sql-2026.9.0.dev1/README.md +52 -0
- rbtr_lang_sql-2026.9.0.dev1/pyproject.toml +58 -0
- rbtr_lang_sql-2026.9.0.dev1/pyproject.toml.orig +62 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/__init__.py +1 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/plugin.py +52 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/py.typed +0 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/sql.scm +70 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__init__.py +0 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_edges_match_snapshot.json +1 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_extraction_matches_snapshot.json +268 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_sql_dialect_extraction_matches_snapshot[sql_clickhouse].json +59 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_sql_dialect_extraction_matches_snapshot[sql_duckdb].json +78 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_sql_dialect_extraction_matches_snapshot[sql_mysql].json +59 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_sql_dialect_extraction_matches_snapshot[sql_postgres].json +116 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/__snapshots__/test_samples/test_sql_dialect_extraction_matches_snapshot[sql_sqlite].json +78 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/cases_extraction.py +265 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/samples/sql/sql.sql +38 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/samples/sql_clickhouse.sql +17 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/samples/sql_duckdb.sql +14 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/samples/sql_mysql.sql +11 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/samples/sql_postgres.sql +18 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/samples/sql_sqlite.sql +11 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/test_extraction.py +85 -0
- rbtr_lang_sql-2026.9.0.dev1/src/rbtr_lang_sql/tests/test_samples.py +115 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alejandro Giacometti
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: rbtr-lang-sql
|
|
3
|
+
Version: 2026.9.0.dev1
|
|
4
|
+
Summary: rbtr — SQL language plugin
|
|
5
|
+
Keywords: code-search,code-index,tree-sitter,static-analysis,semantic-search,developer-tools,sql
|
|
6
|
+
Author: Alejandro Giacometti
|
|
7
|
+
Author-email: Alejandro Giacometti <alejandro.giacometti@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: SQL
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: Topic :: Text Processing :: Indexing
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Dist: rbtr==2026.9.0.dev1
|
|
19
|
+
Requires-Dist: tree-sitter-sql
|
|
20
|
+
Requires-Python: >=3.13
|
|
21
|
+
Project-URL: Homepage, https://github.com/janrito/rbtr
|
|
22
|
+
Project-URL: Repository, https://github.com/janrito/rbtr
|
|
23
|
+
Project-URL: Documentation, https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-sql#readme
|
|
24
|
+
Project-URL: Issues, https://github.com/janrito/rbtr/issues
|
|
25
|
+
Project-URL: Changelog, https://github.com/janrito/rbtr/releases
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# rbtr-lang-sql
|
|
29
|
+
|
|
30
|
+
SQL support for [rbtr]. Optional plugin — install with
|
|
31
|
+
`pip install rbtr[sql]`.
|
|
32
|
+
|
|
33
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
34
|
+
|
|
35
|
+
## What it ingests
|
|
36
|
+
|
|
37
|
+
One chunk per top-level SQL statement (plus one per CTE). SQL has no
|
|
38
|
+
classes or functions in the object-oriented sense and no native import
|
|
39
|
+
mechanism, so statements map onto rbtr's capture conventions by shape:
|
|
40
|
+
structural definitions become classes, routines and executable
|
|
41
|
+
statements become functions, and standalone named objects become
|
|
42
|
+
variables.
|
|
43
|
+
|
|
44
|
+
- **Structural definitions** — `CREATE TABLE`, `CREATE VIEW` /
|
|
45
|
+
`MATERIALIZED VIEW`, `CREATE TYPE ... AS ENUM` / composite types.
|
|
46
|
+
- **Routines & statements** — `CREATE FUNCTION`, `SELECT`, `INSERT`,
|
|
47
|
+
`UPDATE`, `DELETE`, `WITH ... AS` (CTEs), `ALTER` / `DROP`.
|
|
48
|
+
- **Named objects** — `CREATE INDEX` / `SEQUENCE` / `SCHEMA` / `ROLE` /
|
|
49
|
+
`TRIGGER`.
|
|
50
|
+
|
|
51
|
+
`CREATE PROCEDURE` and `PRAGMA` are not extracted — the generic grammar
|
|
52
|
+
has no node for them.
|
|
53
|
+
|
|
54
|
+
## Chunks produced
|
|
55
|
+
|
|
56
|
+
`name` is the statement's target object; `scope` is always empty (SQL
|
|
57
|
+
has no nesting). A statement with no nameable target (`SELECT 1`, a
|
|
58
|
+
`UNION`) carries no name.
|
|
59
|
+
|
|
60
|
+
```sql
|
|
61
|
+
CREATE TABLE users (id INT, name TEXT); -- class "users"
|
|
62
|
+
CREATE VIEW active AS SELECT * FROM users; -- class "active"
|
|
63
|
+
CREATE TYPE mood AS ENUM ('sad','happy'); -- class "mood"
|
|
64
|
+
CREATE FUNCTION add(a INT) ... -- function "add"
|
|
65
|
+
SELECT id, name FROM users; -- function "users"
|
|
66
|
+
INSERT INTO logs (msg) VALUES ('hi'); -- function "logs"
|
|
67
|
+
WITH ranked AS (...) SELECT ... -- function "ranked" (per CTE)
|
|
68
|
+
CREATE INDEX idx_name ON users (name); -- variable "idx_name"
|
|
69
|
+
CREATE SEQUENCE order_id START 1; -- variable "order_id"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Embedded / injected chunks
|
|
73
|
+
|
|
74
|
+
None. SQL does not embed other languages.
|
|
75
|
+
|
|
76
|
+
## Grammar & dependencies
|
|
77
|
+
|
|
78
|
+
Uses the `tree-sitter-sql` grammar (one generic grammar for all
|
|
79
|
+
dialects). No dependency on other language plugins.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# rbtr-lang-sql
|
|
2
|
+
|
|
3
|
+
SQL support for [rbtr]. Optional plugin — install with
|
|
4
|
+
`pip install rbtr[sql]`.
|
|
5
|
+
|
|
6
|
+
[rbtr]: https://github.com/janrito/rbtr/tree/main/packages/rbtr#readme
|
|
7
|
+
|
|
8
|
+
## What it ingests
|
|
9
|
+
|
|
10
|
+
One chunk per top-level SQL statement (plus one per CTE). SQL has no
|
|
11
|
+
classes or functions in the object-oriented sense and no native import
|
|
12
|
+
mechanism, so statements map onto rbtr's capture conventions by shape:
|
|
13
|
+
structural definitions become classes, routines and executable
|
|
14
|
+
statements become functions, and standalone named objects become
|
|
15
|
+
variables.
|
|
16
|
+
|
|
17
|
+
- **Structural definitions** — `CREATE TABLE`, `CREATE VIEW` /
|
|
18
|
+
`MATERIALIZED VIEW`, `CREATE TYPE ... AS ENUM` / composite types.
|
|
19
|
+
- **Routines & statements** — `CREATE FUNCTION`, `SELECT`, `INSERT`,
|
|
20
|
+
`UPDATE`, `DELETE`, `WITH ... AS` (CTEs), `ALTER` / `DROP`.
|
|
21
|
+
- **Named objects** — `CREATE INDEX` / `SEQUENCE` / `SCHEMA` / `ROLE` /
|
|
22
|
+
`TRIGGER`.
|
|
23
|
+
|
|
24
|
+
`CREATE PROCEDURE` and `PRAGMA` are not extracted — the generic grammar
|
|
25
|
+
has no node for them.
|
|
26
|
+
|
|
27
|
+
## Chunks produced
|
|
28
|
+
|
|
29
|
+
`name` is the statement's target object; `scope` is always empty (SQL
|
|
30
|
+
has no nesting). A statement with no nameable target (`SELECT 1`, a
|
|
31
|
+
`UNION`) carries no name.
|
|
32
|
+
|
|
33
|
+
```sql
|
|
34
|
+
CREATE TABLE users (id INT, name TEXT); -- class "users"
|
|
35
|
+
CREATE VIEW active AS SELECT * FROM users; -- class "active"
|
|
36
|
+
CREATE TYPE mood AS ENUM ('sad','happy'); -- class "mood"
|
|
37
|
+
CREATE FUNCTION add(a INT) ... -- function "add"
|
|
38
|
+
SELECT id, name FROM users; -- function "users"
|
|
39
|
+
INSERT INTO logs (msg) VALUES ('hi'); -- function "logs"
|
|
40
|
+
WITH ranked AS (...) SELECT ... -- function "ranked" (per CTE)
|
|
41
|
+
CREATE INDEX idx_name ON users (name); -- variable "idx_name"
|
|
42
|
+
CREATE SEQUENCE order_id START 1; -- variable "order_id"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Embedded / injected chunks
|
|
46
|
+
|
|
47
|
+
None. SQL does not embed other languages.
|
|
48
|
+
|
|
49
|
+
## Grammar & dependencies
|
|
50
|
+
|
|
51
|
+
Uses the `tree-sitter-sql` grammar (one generic grammar for all
|
|
52
|
+
dialects). No dependency on other language plugins.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.11.26,<1"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[tool.uv.build-backend]
|
|
6
|
+
module-name = "rbtr_lang_sql"
|
|
7
|
+
|
|
8
|
+
[tool.uv.sources.rbtr]
|
|
9
|
+
workspace = true
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "rbtr-lang-sql"
|
|
13
|
+
version = "2026.9.0-dev1"
|
|
14
|
+
description = "rbtr — SQL language plugin"
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
license = "MIT"
|
|
17
|
+
license-files = ["LICENSE"]
|
|
18
|
+
keywords = [
|
|
19
|
+
"code-search",
|
|
20
|
+
"code-index",
|
|
21
|
+
"tree-sitter",
|
|
22
|
+
"static-analysis",
|
|
23
|
+
"semantic-search",
|
|
24
|
+
"developer-tools",
|
|
25
|
+
"sql",
|
|
26
|
+
]
|
|
27
|
+
classifiers = [
|
|
28
|
+
"Development Status :: 4 - Beta",
|
|
29
|
+
"Intended Audience :: Developers",
|
|
30
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: SQL",
|
|
33
|
+
"Topic :: Software Development :: Libraries",
|
|
34
|
+
"Topic :: Text Processing :: Indexing",
|
|
35
|
+
"Typing :: Typed",
|
|
36
|
+
]
|
|
37
|
+
requires-python = ">=3.13"
|
|
38
|
+
dependencies = [
|
|
39
|
+
"rbtr==2026.9.0-dev1",
|
|
40
|
+
"tree-sitter-sql",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[[project.authors]]
|
|
44
|
+
name = "Alejandro Giacometti"
|
|
45
|
+
email = "alejandro.giacometti@gmail.com"
|
|
46
|
+
|
|
47
|
+
[project.urls]
|
|
48
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
49
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
50
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-sql#readme"
|
|
51
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
52
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
53
|
+
|
|
54
|
+
[project.entry-points."rbtr.languages"]
|
|
55
|
+
sql = "rbtr_lang_sql.plugin:sql"
|
|
56
|
+
|
|
57
|
+
[dependency-groups]
|
|
58
|
+
dev = ["rbtr[test]"]
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["uv_build>=0.11.26,<1"]
|
|
3
|
+
build-backend = "uv_build"
|
|
4
|
+
|
|
5
|
+
[tool.uv.build-backend]
|
|
6
|
+
module-name = "rbtr_lang_sql"
|
|
7
|
+
# No source-exclude: the plugin's tests, samples, and snapshots ship
|
|
8
|
+
# with the wheel (they are the language's golden record), and sql.scm
|
|
9
|
+
# ships as package data.
|
|
10
|
+
|
|
11
|
+
[project]
|
|
12
|
+
name = "rbtr-lang-sql"
|
|
13
|
+
version = "2026.9.0-dev1"
|
|
14
|
+
description = "rbtr — SQL language plugin"
|
|
15
|
+
readme = "README.md"
|
|
16
|
+
license = "MIT"
|
|
17
|
+
license-files = ["LICENSE"]
|
|
18
|
+
authors = [
|
|
19
|
+
{ name = "Alejandro Giacometti", email = "alejandro.giacometti@gmail.com" },
|
|
20
|
+
]
|
|
21
|
+
keywords = [
|
|
22
|
+
"code-search",
|
|
23
|
+
"code-index",
|
|
24
|
+
"tree-sitter",
|
|
25
|
+
"static-analysis",
|
|
26
|
+
"semantic-search",
|
|
27
|
+
"developer-tools",
|
|
28
|
+
"sql",
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
34
|
+
"Programming Language :: Python :: 3.13",
|
|
35
|
+
"Programming Language :: SQL",
|
|
36
|
+
"Topic :: Software Development :: Libraries",
|
|
37
|
+
"Topic :: Text Processing :: Indexing",
|
|
38
|
+
"Typing :: Typed",
|
|
39
|
+
]
|
|
40
|
+
requires-python = ">=3.13"
|
|
41
|
+
dependencies = [
|
|
42
|
+
"rbtr==2026.9.0-dev1",
|
|
43
|
+
"tree-sitter-sql",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[project.urls]
|
|
47
|
+
Homepage = "https://github.com/janrito/rbtr"
|
|
48
|
+
Repository = "https://github.com/janrito/rbtr"
|
|
49
|
+
Documentation = "https://github.com/janrito/rbtr/tree/main/packages/rbtr-lang-sql#readme"
|
|
50
|
+
Issues = "https://github.com/janrito/rbtr/issues"
|
|
51
|
+
Changelog = "https://github.com/janrito/rbtr/releases"
|
|
52
|
+
|
|
53
|
+
[project.entry-points."rbtr.languages"]
|
|
54
|
+
# The value resolves to the language's `LanguageRegistration` (named by its
|
|
55
|
+
# id) — see the rbtr ARCHITECTURE "External plugins" note.
|
|
56
|
+
sql = "rbtr_lang_sql.plugin:sql"
|
|
57
|
+
|
|
58
|
+
[tool.uv.sources]
|
|
59
|
+
rbtr = { workspace = true }
|
|
60
|
+
|
|
61
|
+
[dependency-groups]
|
|
62
|
+
dev = ["rbtr[test]"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""SQL language plugin package."""
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""SQL language plugin.
|
|
2
|
+
|
|
3
|
+
SQL has no functions/classes in the OO sense and no native import
|
|
4
|
+
mechanism, so constructs map onto rbtr's capture conventions by shape:
|
|
5
|
+
structural definitions are classes, routines and executable statements
|
|
6
|
+
are functions, and standalone named objects are variables. One chunk is
|
|
7
|
+
produced per top-level statement, plus one per CTE.
|
|
8
|
+
|
|
9
|
+
The tree-sitter query lives in `sql.scm`: DDL/ALTER/DROP verbs grouped
|
|
10
|
+
into `[...]` alternations by chunk kind and name location, plus hand-
|
|
11
|
+
written patterns for the DML statements those groups can't express.
|
|
12
|
+
Verified against `tree-sitter-sql` 0.3.11.
|
|
13
|
+
|
|
14
|
+
Extracted chunks::
|
|
15
|
+
|
|
16
|
+
CREATE TABLE users (...) → class "users"
|
|
17
|
+
CREATE VIEW / MATERIALIZED VIEW → class
|
|
18
|
+
CREATE TYPE mood AS ENUM (...) → class "mood"
|
|
19
|
+
|
|
20
|
+
CREATE FUNCTION add(...) ... → function "add"
|
|
21
|
+
SELECT ... FROM users → function "users"
|
|
22
|
+
INSERT INTO logs ... → function "logs"
|
|
23
|
+
UPDATE / DELETE ... t → function "t"
|
|
24
|
+
WITH ranked AS (...) → function "ranked" (one per CTE)
|
|
25
|
+
... UNION ... → function, unnamed
|
|
26
|
+
|
|
27
|
+
CREATE INDEX idx ON users(...) → variable "idx"
|
|
28
|
+
CREATE SEQUENCE / SCHEMA / ROLE … → variable
|
|
29
|
+
CREATE TRIGGER trg ... → variable "trg"
|
|
30
|
+
ALTER / DROP <object> → function "<object>"
|
|
31
|
+
|
|
32
|
+
A statement with no nameable target (`SELECT 1`, a sub-query `FROM`, a
|
|
33
|
+
`UNION`) carries no name. `CREATE PROCEDURE` and `PRAGMA` are not
|
|
34
|
+
extracted — the grammar has no node for them (they parse to `ERROR`).
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
from __future__ import annotations
|
|
38
|
+
|
|
39
|
+
from rbtr.languages.registration import LanguageRegistration, QueryExtraction, load_query
|
|
40
|
+
|
|
41
|
+
# ── Plugin ───────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
sql = LanguageRegistration(
|
|
45
|
+
id="sql",
|
|
46
|
+
extensions=frozenset({".sql"}),
|
|
47
|
+
grammar_module="tree_sitter_sql",
|
|
48
|
+
extraction=QueryExtraction(
|
|
49
|
+
query=load_query(__package__, "sql"),
|
|
50
|
+
),
|
|
51
|
+
extraction_serial=3,
|
|
52
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
; Comments (SQL: `--` line is `comment`, `/* */` block is `marginalia`).
|
|
2
|
+
[(comment) (marginalia)] @comment
|
|
3
|
+
|
|
4
|
+
; DDL/ALTER/DROP verbs, grouped by chunk kind and name location.
|
|
5
|
+
;
|
|
6
|
+
; object_reference names are left unanchored: each verb has exactly one
|
|
7
|
+
; direct object_reference, and leaving it unanchored keeps IF NOT EXISTS /
|
|
8
|
+
; OR REPLACE / TEMP working (anchoring to a keyword breaks when those
|
|
9
|
+
; intervene). A bare (identifier) name (index/schema/role/…) is used when
|
|
10
|
+
; the object_reference, if any, is a secondary reference (e.g. an index's
|
|
11
|
+
; ON table). Verified against tree-sitter-sql 0.3.11.
|
|
12
|
+
|
|
13
|
+
[
|
|
14
|
+
(create_table (object_reference name: (identifier) @_cls_name))
|
|
15
|
+
(create_view (object_reference name: (identifier) @_cls_name))
|
|
16
|
+
(create_materialized_view (object_reference name: (identifier) @_cls_name))
|
|
17
|
+
(create_type (object_reference name: (identifier) @_cls_name))
|
|
18
|
+
] @class
|
|
19
|
+
|
|
20
|
+
(create_sequence (object_reference name: (identifier) @_var_name)) @variable
|
|
21
|
+
|
|
22
|
+
[
|
|
23
|
+
(create_function (object_reference name: (identifier) @_fn_name))
|
|
24
|
+
(alter_table (object_reference name: (identifier) @_fn_name))
|
|
25
|
+
(alter_view (object_reference name: (identifier) @_fn_name))
|
|
26
|
+
(alter_sequence (object_reference name: (identifier) @_fn_name))
|
|
27
|
+
(drop_table (object_reference name: (identifier) @_fn_name))
|
|
28
|
+
(drop_view (object_reference name: (identifier) @_fn_name))
|
|
29
|
+
(drop_sequence (object_reference name: (identifier) @_fn_name))
|
|
30
|
+
(drop_function (object_reference name: (identifier) @_fn_name))
|
|
31
|
+
(drop_type (object_reference name: (identifier) @_fn_name))
|
|
32
|
+
] @function
|
|
33
|
+
|
|
34
|
+
[
|
|
35
|
+
(create_index (identifier) @_var_name)
|
|
36
|
+
(create_schema (identifier) @_var_name)
|
|
37
|
+
(create_database (identifier) @_var_name)
|
|
38
|
+
(create_extension (identifier) @_var_name)
|
|
39
|
+
(create_role (identifier) @_var_name)
|
|
40
|
+
] @variable
|
|
41
|
+
|
|
42
|
+
[
|
|
43
|
+
(alter_index (identifier) @_fn_name)
|
|
44
|
+
(alter_schema (identifier) @_fn_name)
|
|
45
|
+
(alter_database (identifier) @_fn_name)
|
|
46
|
+
(alter_role (identifier) @_fn_name)
|
|
47
|
+
(alter_type (identifier) @_fn_name)
|
|
48
|
+
(drop_index (identifier) @_fn_name)
|
|
49
|
+
(drop_schema (identifier) @_fn_name)
|
|
50
|
+
(drop_database (identifier) @_fn_name)
|
|
51
|
+
(drop_role (identifier) @_fn_name)
|
|
52
|
+
(drop_extension (identifier) @_fn_name)
|
|
53
|
+
] @function
|
|
54
|
+
|
|
55
|
+
; DML statements, CTEs, triggers, and set operations — structures the DDL
|
|
56
|
+
; groups can't express. DML patterns are anchored at (program (statement …))
|
|
57
|
+
; so each top-level statement yields exactly one chunk: select and delete
|
|
58
|
+
; keep their target in a sibling from, so the whole statement is captured.
|
|
59
|
+
; A set_operation (UNION/INTERSECT/EXCEPT) has no single table → unnamed.
|
|
60
|
+
|
|
61
|
+
(create_trigger (keyword_trigger) . (object_reference name: (identifier) @_var_name)) @variable
|
|
62
|
+
|
|
63
|
+
(cte (identifier) @_fn_name) @function
|
|
64
|
+
|
|
65
|
+
(program (statement (select)
|
|
66
|
+
(from (relation (object_reference name: (identifier) @_fn_name)))?) @function)
|
|
67
|
+
(program (statement (set_operation) @function))
|
|
68
|
+
(program (statement (insert (object_reference name: (identifier) @_fn_name))) @function)
|
|
69
|
+
(program (statement (update (relation (object_reference name: (identifier) @_fn_name)))) @function)
|
|
70
|
+
(program (statement (delete) (from (object_reference name: (identifier) @_fn_name))) @function)
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"blob_sha": "sha1",
|
|
4
|
+
"file_path": "sql.sql",
|
|
5
|
+
"kind": "comment",
|
|
6
|
+
"name": "",
|
|
7
|
+
"scope": "",
|
|
8
|
+
"language": "sql",
|
|
9
|
+
"file_language": "sql",
|
|
10
|
+
"content": "-- Greeter schema — tables, views, and statements for greetings.\n--\n-- The SQL plugin extracts one chunk per top-level statement: CREATE\n-- TABLE/VIEW (as classes), CREATE FUNCTION and DML/CTEs (as functions),\n-- and CREATE SCHEMA/INDEX/SEQUENCE (as variables). There is no import\n-- concept. CREATE PROCEDURE and PRAGMA do not parse and live in the\n-- xfail registry instead.",
|
|
11
|
+
"line_start": 1,
|
|
12
|
+
"line_end": 7,
|
|
13
|
+
"metadata": {
|
|
14
|
+
"module": "",
|
|
15
|
+
"names": "",
|
|
16
|
+
"dots": "",
|
|
17
|
+
"language_hint": ""
|
|
18
|
+
},
|
|
19
|
+
"id": "fcb24b55c55b71af"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"blob_sha": "sha1",
|
|
23
|
+
"file_path": "sql.sql",
|
|
24
|
+
"kind": "variable",
|
|
25
|
+
"name": "greet",
|
|
26
|
+
"scope": "",
|
|
27
|
+
"language": "sql",
|
|
28
|
+
"file_language": "sql",
|
|
29
|
+
"content": "CREATE SCHEMA greet",
|
|
30
|
+
"line_start": 9,
|
|
31
|
+
"line_end": 9,
|
|
32
|
+
"metadata": {
|
|
33
|
+
"module": "",
|
|
34
|
+
"names": "",
|
|
35
|
+
"dots": "",
|
|
36
|
+
"language_hint": ""
|
|
37
|
+
},
|
|
38
|
+
"id": "2bf9543268256917"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"blob_sha": "sha1",
|
|
42
|
+
"file_path": "sql.sql",
|
|
43
|
+
"kind": "comment",
|
|
44
|
+
"name": "",
|
|
45
|
+
"scope": "",
|
|
46
|
+
"language": "sql",
|
|
47
|
+
"file_language": "sql",
|
|
48
|
+
"content": "-- trailing comment: its own chunk",
|
|
49
|
+
"line_start": 9,
|
|
50
|
+
"line_end": 9,
|
|
51
|
+
"metadata": {
|
|
52
|
+
"module": "",
|
|
53
|
+
"names": "",
|
|
54
|
+
"dots": "",
|
|
55
|
+
"language_hint": ""
|
|
56
|
+
},
|
|
57
|
+
"id": "98756ee52a748b1e"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"blob_sha": "sha1",
|
|
61
|
+
"file_path": "sql.sql",
|
|
62
|
+
"kind": "comment",
|
|
63
|
+
"name": "",
|
|
64
|
+
"scope": "",
|
|
65
|
+
"language": "sql",
|
|
66
|
+
"file_language": "sql",
|
|
67
|
+
"content": "-- Standalone note, separated by blank lines from any statement.\n-- Second line of the same block.",
|
|
68
|
+
"line_start": 11,
|
|
69
|
+
"line_end": 12,
|
|
70
|
+
"metadata": {
|
|
71
|
+
"module": "",
|
|
72
|
+
"names": "",
|
|
73
|
+
"dots": "",
|
|
74
|
+
"language_hint": ""
|
|
75
|
+
},
|
|
76
|
+
"id": "0c438a2a19d6d59e"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"blob_sha": "sha1",
|
|
80
|
+
"file_path": "sql.sql",
|
|
81
|
+
"kind": "class",
|
|
82
|
+
"name": "greeters",
|
|
83
|
+
"scope": "",
|
|
84
|
+
"language": "sql",
|
|
85
|
+
"file_language": "sql",
|
|
86
|
+
"content": "CREATE TABLE greeters (\n id INTEGER PRIMARY KEY,\n prefix TEXT NOT NULL\n)",
|
|
87
|
+
"line_start": 14,
|
|
88
|
+
"line_end": 17,
|
|
89
|
+
"metadata": {
|
|
90
|
+
"module": "",
|
|
91
|
+
"names": "",
|
|
92
|
+
"dots": "",
|
|
93
|
+
"language_hint": ""
|
|
94
|
+
},
|
|
95
|
+
"id": "119e8882c4026de1"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"blob_sha": "sha1",
|
|
99
|
+
"file_path": "sql.sql",
|
|
100
|
+
"kind": "variable",
|
|
101
|
+
"name": "idx_greeters_prefix",
|
|
102
|
+
"scope": "",
|
|
103
|
+
"language": "sql",
|
|
104
|
+
"file_language": "sql",
|
|
105
|
+
"content": "CREATE INDEX idx_greeters_prefix ON greeters (prefix)",
|
|
106
|
+
"line_start": 19,
|
|
107
|
+
"line_end": 19,
|
|
108
|
+
"metadata": {
|
|
109
|
+
"module": "",
|
|
110
|
+
"names": "",
|
|
111
|
+
"dots": "",
|
|
112
|
+
"language_hint": ""
|
|
113
|
+
},
|
|
114
|
+
"id": "ab3497f2cf28a336"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"blob_sha": "sha1",
|
|
118
|
+
"file_path": "sql.sql",
|
|
119
|
+
"kind": "variable",
|
|
120
|
+
"name": "greeting_id_seq",
|
|
121
|
+
"scope": "",
|
|
122
|
+
"language": "sql",
|
|
123
|
+
"file_language": "sql",
|
|
124
|
+
"content": "CREATE SEQUENCE greeting_id_seq",
|
|
125
|
+
"line_start": 21,
|
|
126
|
+
"line_end": 21,
|
|
127
|
+
"metadata": {
|
|
128
|
+
"module": "",
|
|
129
|
+
"names": "",
|
|
130
|
+
"dots": "",
|
|
131
|
+
"language_hint": ""
|
|
132
|
+
},
|
|
133
|
+
"id": "1fdfd3531b021310"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"blob_sha": "sha1",
|
|
137
|
+
"file_path": "sql.sql",
|
|
138
|
+
"kind": "class",
|
|
139
|
+
"name": "active_greeters",
|
|
140
|
+
"scope": "",
|
|
141
|
+
"language": "sql",
|
|
142
|
+
"file_language": "sql",
|
|
143
|
+
"content": "CREATE VIEW active_greeters AS\nSELECT id, prefix FROM greeters WHERE prefix IS NOT NULL",
|
|
144
|
+
"line_start": 23,
|
|
145
|
+
"line_end": 24,
|
|
146
|
+
"metadata": {
|
|
147
|
+
"module": "",
|
|
148
|
+
"names": "",
|
|
149
|
+
"dots": "",
|
|
150
|
+
"language_hint": ""
|
|
151
|
+
},
|
|
152
|
+
"id": "42074e751143db09"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"blob_sha": "sha1",
|
|
156
|
+
"file_path": "sql.sql",
|
|
157
|
+
"kind": "function",
|
|
158
|
+
"name": "shout",
|
|
159
|
+
"scope": "",
|
|
160
|
+
"language": "sql",
|
|
161
|
+
"file_language": "sql",
|
|
162
|
+
"content": "CREATE FUNCTION shout(message TEXT) RETURNS TEXT AS 'SELECT upper(message)'",
|
|
163
|
+
"line_start": 26,
|
|
164
|
+
"line_end": 26,
|
|
165
|
+
"metadata": {
|
|
166
|
+
"module": "",
|
|
167
|
+
"names": "",
|
|
168
|
+
"dots": "",
|
|
169
|
+
"language_hint": ""
|
|
170
|
+
},
|
|
171
|
+
"id": "e809c9a3ee5d5686"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"blob_sha": "sha1",
|
|
175
|
+
"file_path": "sql.sql",
|
|
176
|
+
"kind": "function",
|
|
177
|
+
"name": "recent",
|
|
178
|
+
"scope": "",
|
|
179
|
+
"language": "sql",
|
|
180
|
+
"file_language": "sql",
|
|
181
|
+
"content": "WITH recent AS (\n SELECT id FROM greeters\n)\n\nSELECT id FROM recent",
|
|
182
|
+
"line_start": 28,
|
|
183
|
+
"line_end": 32,
|
|
184
|
+
"metadata": {
|
|
185
|
+
"module": "",
|
|
186
|
+
"names": "",
|
|
187
|
+
"dots": "",
|
|
188
|
+
"language_hint": ""
|
|
189
|
+
},
|
|
190
|
+
"id": "330f6d8ac830cc9f"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"blob_sha": "sha1",
|
|
194
|
+
"file_path": "sql.sql",
|
|
195
|
+
"kind": "function",
|
|
196
|
+
"name": "recent",
|
|
197
|
+
"scope": "",
|
|
198
|
+
"language": "sql",
|
|
199
|
+
"file_language": "sql",
|
|
200
|
+
"content": "recent AS (\n SELECT id FROM greeters\n)",
|
|
201
|
+
"line_start": 28,
|
|
202
|
+
"line_end": 30,
|
|
203
|
+
"metadata": {
|
|
204
|
+
"module": "",
|
|
205
|
+
"names": "",
|
|
206
|
+
"dots": "",
|
|
207
|
+
"language_hint": ""
|
|
208
|
+
},
|
|
209
|
+
"id": "a2b86ca2dd9035b0"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"blob_sha": "sha1",
|
|
213
|
+
"file_path": "sql.sql",
|
|
214
|
+
"kind": "function",
|
|
215
|
+
"name": "greeters",
|
|
216
|
+
"scope": "",
|
|
217
|
+
"language": "sql",
|
|
218
|
+
"file_language": "sql",
|
|
219
|
+
"content": "INSERT INTO greeters (id, prefix) VALUES (1, 'Hello')",
|
|
220
|
+
"line_start": 34,
|
|
221
|
+
"line_end": 34,
|
|
222
|
+
"metadata": {
|
|
223
|
+
"module": "",
|
|
224
|
+
"names": "",
|
|
225
|
+
"dots": "",
|
|
226
|
+
"language_hint": ""
|
|
227
|
+
},
|
|
228
|
+
"id": "c68ef3a9070b8b98"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"blob_sha": "sha1",
|
|
232
|
+
"file_path": "sql.sql",
|
|
233
|
+
"kind": "function",
|
|
234
|
+
"name": "greeters",
|
|
235
|
+
"scope": "",
|
|
236
|
+
"language": "sql",
|
|
237
|
+
"file_language": "sql",
|
|
238
|
+
"content": "UPDATE greeters SET prefix = 'Hi' WHERE id = 1",
|
|
239
|
+
"line_start": 36,
|
|
240
|
+
"line_end": 36,
|
|
241
|
+
"metadata": {
|
|
242
|
+
"module": "",
|
|
243
|
+
"names": "",
|
|
244
|
+
"dots": "",
|
|
245
|
+
"language_hint": ""
|
|
246
|
+
},
|
|
247
|
+
"id": "f9b1fae7ce538957"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
"blob_sha": "sha1",
|
|
251
|
+
"file_path": "sql.sql",
|
|
252
|
+
"kind": "function",
|
|
253
|
+
"name": "greeters",
|
|
254
|
+
"scope": "",
|
|
255
|
+
"language": "sql",
|
|
256
|
+
"file_language": "sql",
|
|
257
|
+
"content": "DELETE FROM greeters WHERE id = 1",
|
|
258
|
+
"line_start": 38,
|
|
259
|
+
"line_end": 38,
|
|
260
|
+
"metadata": {
|
|
261
|
+
"module": "",
|
|
262
|
+
"names": "",
|
|
263
|
+
"dots": "",
|
|
264
|
+
"language_hint": ""
|
|
265
|
+
},
|
|
266
|
+
"id": "6af17e06c316e1a8"
|
|
267
|
+
}
|
|
268
|
+
]
|