sqlsift-lsp 0.1.0 → 0.1.3

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.
package/CHANGELOG.md CHANGED
@@ -7,151 +7,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.1.0-alpha.8] - 2026-02-13
11
-
12
- ### Changed
13
- - **Project renamed from sqlsurge to sqlsift** to avoid name conflict with existing [senkenn/sqlsurge](https://github.com/senkenn/sqlsurge) VS Code extension
14
- - crate names: `sqlsift-core`, `sqlsift-cli`, `sqlsift-lsp`
15
- - npm package: `sqlsift-cli`
16
- - binary: `sqlsift`
17
- - config file: `sqlsift.toml`
18
-
19
- ### Fixed
20
- - Fix `auto-tag.yml` release automation: add `actions: write` permission to enable `gh workflow run`
21
-
22
- ## [0.1.0-alpha.7] - 2026-02-11
10
+ ## [0.1.3](https://github.com/yukikotani231/sqlsift/compare/v0.1.2...v0.1.3) - 2026-03-04
23
11
 
24
12
  ### Added
25
- - **LSP server** (`sqlsift-lsp`): Language Server Protocol support for real-time SQL diagnostics in editors
26
- - textDocument/didOpen, didChange, didSave, didClose
27
- - Automatic schema loading from `sqlsift.toml`
28
- - Schema file change detection with catalog rebuild
29
- - Diagnostic severity, error codes, and help messages
30
- - 12 unit tests (diagnostic conversion, state management)
31
- - **VS Code extension** (`editors/vscode/`): Thin LSP client for VS Code
32
- - Configurable server path via `sqlsift.serverPath` setting
33
- - SQL language configuration (comments, brackets)
34
- - **Neovim support**: Works out of the box with built-in LSP client
35
-
36
- ### Fixed
37
- - `SELECT *` diagnostic now points to the `SELECT` keyword instead of file start
38
-
39
- ## [0.1.0-alpha.6] - 2026-02-08
40
13
 
41
- ### Added
42
- - **Type inference engine**: SQL expression type checking for WHERE clauses and JOIN conditions
43
- - E0003 (type-mismatch): Detect incompatible type comparisons (e.g., `WHERE id = 'text'`)
44
- - E0007 (join-type-mismatch): Detect JOIN condition type incompatibilities (e.g., `ON users.id = orders.name`)
45
- - Binary operator type validation: comparisons (=, !=, <, >, <=, >=) and arithmetic (+, -, *, /)
46
- - Nested expression type inference: `(a + b) * 2 = c`
47
- - Numeric type compatibility: implicit casts between TINYINT, SMALLINT, INTEGER, BIGINT
48
-
49
- ### Changed
50
- - Reorganized test suite: moved integration tests to `tests/analyzer_tests.rs` (74 tests)
51
- - Improved API documentation with doc-test examples
52
- - Replaced `unwrap()` with `expect()` in catalog code for better error messages
14
+ - validate set operations and wire CLI runtime flags ([#65](https://github.com/yukikotani231/sqlsift/pull/65))
53
15
 
54
- ## [0.1.0-alpha.5] - 2026-02-08
16
+ ### Other
55
17
 
56
- ### Added
57
- - **MySQL dialect support**: Full schema parsing and query validation for MySQL
58
- - MySQL-specific types: `TINYINT`, `MEDIUMINT`, `UNSIGNED` integer variants, `DATETIME`, inline `ENUM`
59
- - `AUTO_INCREMENT` handling with implicit NOT NULL inference
60
- - 10 MySQL unit tests covering schema parsing, SELECT, JOIN, INSERT, UPDATE, DELETE, subquery, CTE, and error detection
61
- - Real-world MySQL test fixtures:
62
- - **Sakila** (BSD): 16 tables, 40 valid queries, 12 error detection tests
63
- - **Chinook MySQL** (MIT): 11 tables, 40 valid queries, 12 error detection tests
18
+ - refresh outdated capability notes ([#63](https://github.com/yukikotani231/sqlsift/pull/63))
64
19
 
65
- ## [0.1.0-alpha.4] - 2026-02-08
20
+ ## [0.1.2](https://github.com/yukikotani231/sqlsift/compare/v0.1.1...v0.1.2) - 2026-02-19
66
21
 
67
22
  ### Added
68
- - **Derived table (subquery in FROM) support**: Resolve aliases and validate column references for `FROM (SELECT ...) AS sub`
69
- - **LATERAL vs non-LATERAL scope isolation**: Non-LATERAL subqueries correctly cannot see outer FROM tables
70
- - **UPDATE ... FROM / DELETE ... USING**: PostgreSQL-specific multi-table update/delete syntax
71
- - **Recursive CTE support**: CTEs can reference themselves in recursive queries
72
- - **Table-valued functions in FROM**: `generate_series()`, `unnest()` etc. recognized as table sources
73
- - **UNION/INTERSECT/EXCEPT column inference**: Infer output columns from set operations for CTE/derived table validation
74
- - **Comprehensive expression resolution**: AtTimeZone, Collate, Ceil/Floor, Overlay, IsDistinctFrom, IsUnknown, SimilarTo, Tuple, Array, Subscript, Method, GroupingSets/Cube/Rollup
75
- - **Function FILTER/OVER clause resolution**: Validate column references in `COUNT(*) FILTER (WHERE ...)` and `OVER (PARTITION BY ... ORDER BY ...)`
76
- - **ORDER BY column resolution**: Validate ORDER BY references including SELECT alias support
77
- - **Named function argument resolution**: Handle `func(name => value)` syntax
78
- - 72 PostgreSQL pattern test fixtures (basic, advanced, and expression coverage)
79
-
80
- ### Fixed
81
- - WHERE subquery scope leak: subqueries in IN/EXISTS no longer pollute outer table scope
82
- - VALUES derived table column aliases now correctly applied
83
- - Empty derived_columns (table-valued functions) no longer cause false column-not-found errors
84
-
85
- ## [0.1.0-alpha.3] - 2026-02-08
86
23
 
87
- ### Added
88
- - **`--dialect` flag wired up**: CLI `--dialect` option now correctly configures the SQL parser dialect (previously ignored)
89
- - **Real-world schema test fixtures**: Chinook, Pagila, Northwind schemas with comprehensive valid/invalid query tests covering SELECT, JOIN, INSERT, UPDATE, DELETE, subqueries, and CTEs
90
- - Third-party license file for test fixtures
91
-
92
- ### Fixed
93
- - `--dialect` CLI flag was completely ignored; PostgreSQL dialect was hardcoded throughout
94
- - ALTER TABLE warnings for non-schema-affecting operations (e.g., `OWNER TO`) are now suppressed
24
+ - add LSP auto-completion for table/column/view names ([#53](https://github.com/yukikotani231/sqlsift/pull/53))
25
+ - add inline comment directives for diagnostic suppression ([#52](https://github.com/yukikotani231/sqlsift/pull/52))
26
+ - add textDocument/hover for table, view, and column info ([#49](https://github.com/yukikotani231/sqlsift/pull/49))
95
27
 
96
- ## [0.1.0-alpha.2] - 2026-02-08
28
+ ### Other
97
29
 
98
- ### Added
99
- - **CHECK constraints**: Column-level and table-level CHECK constraint parsing and storage
100
- - **CREATE TYPE AS ENUM**: Enum type definitions with value storage in catalog
101
- - **GENERATED AS IDENTITY**: ALWAYS and BY DEFAULT identity columns with implicit NOT NULL
102
- - **CREATE VIEW**: View definitions with column inference from SELECT projection, wildcard expansion, and query-time resolution
103
- - **ALTER TABLE**: ADD COLUMN, DROP COLUMN, RENAME COLUMN, RENAME TABLE, ADD CONSTRAINT support
104
- - **Resilient SQL parsing**: Gracefully skip unsupported DDL statements (CREATE FUNCTION, CREATE TRIGGER, CREATE DOMAIN, etc.) instead of failing the entire schema file
105
- - Real-world test fixtures from Sakila and webknossos schemas
30
+ - add GitHub templates and CI integration examples ([#54](https://github.com/yukikotani231/sqlsift/pull/54))
106
31
 
107
- ### Fixed
108
- - Schema files with mixed supported/unsupported SQL statements now parse correctly
109
- - Comments preceding DDL statements no longer cause statement-by-statement parsing to skip valid statements
32
+ ## [0.1.1](https://github.com/yukikotani231/sqlsift/compare/sqlsift-lsp-v0.1.0...sqlsift-lsp-v0.1.1) - 2026-02-14
110
33
 
111
- ### Changed
112
- - Known Limitations updated: VIEWs are now supported; ALTER TABLE is now supported
34
+ ### Other
113
35
 
114
- ## [0.1.0-alpha.1] - 2026-02-07
115
-
116
- ### Added
117
- - Initial release of sqlsift
118
- - SQL static analysis against schema definitions
119
- - Support for PostgreSQL dialect
120
- - Schema parsing from CREATE TABLE statements
121
- - Query validation for SELECT, INSERT, UPDATE, DELETE statements
122
- - Error detection:
123
- - E0001: Table not found
124
- - E0002: Column not found
125
- - E0003: Type mismatch (reserved)
126
- - E0004: Potential NULL violation (reserved)
127
- - E0005: Column count mismatch in INSERT
128
- - E0006: Ambiguous column reference
129
- - E0007: JOIN type mismatch (reserved)
130
- - E1000: Parse error
131
- - JOIN condition validation
132
- - Subquery support (including correlated subqueries)
133
- - CTE (Common Table Expressions) support
134
- - Error position reporting (line and column numbers)
135
- - Multiple output formats: human-readable, JSON, SARIF
136
- - Configuration file support (sqlsift.toml)
137
- - Rule disabling via CLI (--disable) or config file
138
- - CLI with check, schema, and parse commands
139
- - Typo suggestions using Levenshtein distance
140
- - CI/CD integration support via exit codes and SARIF output
141
- - Framework integration examples (Rails, Prisma)
142
-
143
- ### Known Limitations
144
- - Only PostgreSQL dialect fully supported
145
- - Type checking is basic (existence only, not full type inference)
146
- - No support for VIEWs, functions, or stored procedures
147
- - Derived table (subquery in FROM) column resolution is incomplete
148
-
149
- [Unreleased]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.8...HEAD
150
- [0.1.0-alpha.8]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.7...v0.1.0-alpha.8
151
- [0.1.0-alpha.7]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.6...v0.1.0-alpha.7
152
- [0.1.0-alpha.6]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.5...v0.1.0-alpha.6
153
- [0.1.0-alpha.5]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.4...v0.1.0-alpha.5
154
- [0.1.0-alpha.4]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.3...v0.1.0-alpha.4
155
- [0.1.0-alpha.3]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.2...v0.1.0-alpha.3
156
- [0.1.0-alpha.2]: https://github.com/yukikotani231/sqlsift/compare/v0.1.0-alpha.1...v0.1.0-alpha.2
157
- [0.1.0-alpha.1]: https://github.com/yukikotani231/sqlsift/releases/tag/v0.1.0-alpha.1
36
+ - update README and CLAUDE.md for current state
37
+ - Rename project from sqlsurge to sqlsift
38
+ - add comprehensive TODO documentation for type inference
39
+ - Prepare v0.1.0-alpha.5 release
40
+ - Update docs to reflect current PostgreSQL support level
41
+ - Update README and CLAUDE.md to reflect current features
42
+ - Prepare v0.1.0-alpha.1 release
43
+ - Add npm package distribution via cargo-dist
44
+ - Fix GitHub username in URLs
45
+ - Add README, CLAUDE.md, and CI workflow
package/README.md CHANGED
@@ -134,18 +134,39 @@ sqlsift check --schema schema/*.sql queries/**/*.sql
134
134
  - ✅ WHERE clause comparisons (`WHERE id = 'text'`)
135
135
  - ✅ Arithmetic operations (`SELECT name + 10`)
136
136
  - ✅ JOIN conditions (`ON users.id = orders.user_name`)
137
+ - ✅ Set operations column validation (`UNION` / `INTERSECT` / `EXCEPT` column count and type compatibility)
137
138
  - ✅ INSERT value type mismatches (`INSERT INTO users (id) VALUES ('text')`)
138
139
  - ✅ UPDATE assignment type mismatches (`UPDATE users SET id = 'text'`)
140
+ - ✅ CAST expression type inference (`CAST(name AS INTEGER)`)
141
+ - ✅ Function return type inference (e.g., `COUNT`, `SUM`, `UPPER`, `LENGTH`, `COALESCE`)
139
142
  - ✅ Nested expressions (`WHERE (a + b) * 2 = 'text'`)
140
143
  - ✅ All comparison operators (=, !=, <, >, <=, >=)
141
144
  - ✅ Numeric type compatibility (INTEGER, BIGINT, DECIMAL, etc.)
142
145
 
143
146
  **Not Yet Detected:**
144
- - ⏳ CAST expression type inference
145
- - ⏳ Function return types (COUNT, SUM, AVG, etc.)
146
147
  - ⏳ CASE expression type consistency
147
148
  - ⏳ Subquery/CTE column type inference
148
149
 
150
+ ### Inline Suppression
151
+
152
+ Suppress diagnostics on specific lines using SQL comments:
153
+
154
+ ```sql
155
+ -- Suppress a specific rule on the next line
156
+ -- sqlsift:disable E0002
157
+ SELECT legacy_col FROM users;
158
+
159
+ -- Suppress on the same line
160
+ SELECT legacy_col FROM users; -- sqlsift:disable E0002
161
+
162
+ -- Suppress multiple rules
163
+ SELECT bad_col FROM missing_table; -- sqlsift:disable E0001, E0002
164
+
165
+ -- Suppress all rules on the next line
166
+ -- sqlsift:disable
167
+ SELECT bad_col FROM missing_table;
168
+ ```
169
+
149
170
  ## CLI Reference
150
171
 
151
172
  ```
@@ -161,9 +182,9 @@ Options:
161
182
  --disable <RULE> Disable specific rules (e.g., E0001, E0002)
162
183
  -d, --dialect <NAME> SQL dialect [default: postgresql]
163
184
  -f, --format <FORMAT> Output format: human, json, sarif [default: human]
164
- --max-errors <N> Maximum number of errors before stopping [default: 100]
165
- -v, --verbose Enable verbose output
166
- -q, --quiet Suppress non-error output
185
+ --max-errors <N> Maximum number of errors before stopping [default: 100, 0 = unlimited]
186
+ -v, --verbose Enable verbose logging (-vv for debug)
187
+ -q, --quiet Suppress summary/non-error output
167
188
  -h, --help Print help
168
189
  ```
169
190
 
@@ -193,6 +214,46 @@ sqlsift check -s schema.sql -f json queries/*.sql
193
214
  sqlsift check -s schema.sql -f sarif queries/*.sql > results.sarif
194
215
  ```
195
216
 
217
+ ## CI Integration
218
+
219
+ ### GitHub Actions
220
+
221
+ Add sqlsift to your CI pipeline to catch SQL errors in pull requests:
222
+
223
+ ```yaml
224
+ # .github/workflows/sqlsift.yml
225
+ name: SQL Lint
226
+ on: [push, pull_request]
227
+ jobs:
228
+ sqlsift:
229
+ runs-on: ubuntu-latest
230
+ steps:
231
+ - uses: actions/checkout@v4
232
+ - run: npx sqlsift-cli check --schema schema.sql queries/*.sql
233
+ ```
234
+
235
+ ### GitHub Code Scanning (SARIF)
236
+
237
+ Upload results to GitHub's Security tab:
238
+
239
+ ```yaml
240
+ # .github/workflows/sqlsift.yml
241
+ name: SQL Lint
242
+ on: [push, pull_request]
243
+ jobs:
244
+ sqlsift:
245
+ runs-on: ubuntu-latest
246
+ permissions:
247
+ security-events: write
248
+ steps:
249
+ - uses: actions/checkout@v4
250
+ - run: npx sqlsift-cli check -s schema.sql -f sarif queries/*.sql > results.sarif
251
+ continue-on-error: true
252
+ - uses: github/codeql-action/upload-sarif@v3
253
+ with:
254
+ sarif_file: results.sarif
255
+ ```
256
+
196
257
  ## Supported SQL Queries
197
258
 
198
259
  - SELECT, INSERT, UPDATE, DELETE with full column/table validation
@@ -235,8 +296,6 @@ Use the `--dialect` flag to specify the dialect.
235
296
  - [x] LSP server for editor integration (VS Code extension)
236
297
 
237
298
  ### Planned
238
- - [ ] CAST expression type inference
239
- - [ ] Function return type inference (COUNT, SUM, AVG, etc.)
240
299
  - [ ] CASE expression type consistency checking
241
300
  - [ ] Subquery/CTE column type inference
242
301
  - [ ] Custom rule plugins
@@ -23,7 +23,7 @@
23
23
  "hasInstallScript": true,
24
24
  "license": "MIT",
25
25
  "name": "sqlsift-lsp",
26
- "version": "0.1.0"
26
+ "version": "0.1.3"
27
27
  },
28
28
  "node_modules/@isaacs/balanced-match": {
29
29
  "engines": {
@@ -515,5 +515,5 @@
515
515
  }
516
516
  },
517
517
  "requires": true,
518
- "version": "0.1.0"
518
+ "version": "0.1.3"
519
519
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "artifactDownloadUrl": "https://github.com/yukikotani231/sqlsift/releases/download/v0.1.0",
2
+ "artifactDownloadUrl": "https://github.com/yukikotani231/sqlsift/releases/download/v0.1.3",
3
3
  "bin": {
4
4
  "sqlsift-lsp": "run-sqlsift-lsp.js"
5
5
  },
@@ -91,7 +91,7 @@
91
91
  "zipExt": ".tar.xz"
92
92
  }
93
93
  },
94
- "version": "0.1.0",
94
+ "version": "0.1.3",
95
95
  "volta": {
96
96
  "node": "18.14.1",
97
97
  "npm": "9.5.0"