Skip to content

Commit 0ac1a90

Browse files
ajitpratap0Ajit Pratap Singhclaude
authored
docs: comprehensive godoc documentation update across all packages (#186)
* docs: update documentation to reflect v1.6.0 features as available This commit updates all documentation to reflect that v1.6.0 features are now available (not planned): Migration Guides: - FROM_SQLFLUFF.md: Updated linting rules (10 rules L001-L010), auto-fix, VSCode extension, and .gosqlx.yml config as available in v1.6.0 - FROM_PG_QUERY.md: Updated JSON/JSONB operators as supported in v1.6.0 Documentation Updates: - Updated version references from v1.5.x to v1.6.0 across all docs - Added v1.6.0 upgrade section to UPGRADE_GUIDE.md - Updated COMPARISON.md with v1.6.0 features and performance data - Updated CLAUDE.md production status to v1.6.0+ - Updated performance_baselines.json to v1.6.0 Key v1.6.0 Features Now Documented: - PostgreSQL Extensions (LATERAL JOIN, JSON/JSONB operators, DISTINCT ON) - Language Server Protocol (LSP) server - VSCode Extension - 10 Linting Rules (L001-L010) with auto-fix - .gosqlx.yml configuration file support - go-task Taskfile.yml - Structured error codes (E1001-E3004) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: comprehensive v1.6.0 feature documentation update Based on parallel agent review of all documentation, this commit updates: Migration Guides: - FROM_SQLFLUFF.md: Fixed "Coming in v1.5.0" → "Available in v1.6.0" for linting - FROM_SQLFLUFF.md: Updated FAQ to reflect 10 linting rules now available - FROM_PG_QUERY.md: Fixed "planned for v1.5.0" → "planned for future release" SQL Compatibility (SQL_COMPATIBILITY.md): - LATERAL JOIN: Updated from "10% Syntax" to "95% Full support" - JSON/JSONB: Updated from "30% Syntax" to "95% Full support" with all operators - Added DISTINCT ON: 95% Full support - Added FILTER clause: 95% Full support - Added RETURNING clause: 95% Full support Comparison Guide (COMPARISON.md): - Updated linting from "❌ Planned" to "✅ 10 rules (L001-L010)" - Updated limitations section to reflect 10 rules available Documentation Index (docs/README.md): - Updated all document versions from v1.5.1 to v1.6.0 - Updated dates from 2025-11 to 2025-12 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: add dedicated LSP, linting, and configuration guides with PostgreSQL examples New Documentation: - docs/LSP_GUIDE.md: Complete Language Server Protocol guide covering IDE integration, features, error codes, and troubleshooting - docs/LINTING_RULES.md: Full reference for all 10 linting rules (L001-L010) with examples, severity levels, and auto-fix capabilities - docs/CONFIGURATION.md: Comprehensive configuration guide for .gosqlx.yml with schema documentation, defaults, and best practices New PostgreSQL Feature Examples: - examples/postgresql/lateral-join/: LATERAL JOIN parsing demonstrations - examples/postgresql/jsonb-operators/: JSON/JSONB operator support (->/->>/#>/#>>/@>/<@/?/?|/?&/#-) - examples/postgresql/filter-clause/: FILTER clause for conditional aggregation - examples/postgresql/returning-clause/: RETURNING clause for DML statements Updated: - examples/README.md: Added new examples to documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: comprehensive godoc documentation update across all packages This commit adds professional-quality Go documentation to all packages, following Go best practices with detailed package-level doc.go files. ## New Package Documentation Files (24 doc.go files) ### SQL Core Packages - pkg/sql/doc.go - SQL processing pipeline overview - pkg/sql/parser/doc.go - Recursive descent parser (~300 lines) - pkg/sql/tokenizer/doc.go - Zero-copy tokenizer documentation - pkg/sql/ast/doc.go - AST nodes and visitor pattern - pkg/sql/keywords/doc.go - Multi-dialect keyword handling - pkg/sql/token/doc.go - Parser token types - pkg/sql/monitor/doc.go - Lightweight monitoring ### Supporting Packages - pkg/metrics/doc.go - Production monitoring (~440 lines) - pkg/errors/doc.go - Structured error handling - pkg/models/doc.go - Core data structures - pkg/config/doc.go - Configuration management - pkg/compatibility/doc.go - Backward compatibility testing - pkg/gosqlx/doc.go - High-level API - pkg/gosqlx/testing/doc.go - Test helper utilities ### Linter Packages - pkg/linter/doc.go - SQL linting engine - pkg/linter/rules/keywords/doc.go - Keyword rules - pkg/linter/rules/style/doc.go - Style rules - pkg/linter/rules/whitespace/doc.go - Whitespace rules ### CLI Packages - cmd/gosqlx/doc.go - CLI tool entry point - cmd/gosqlx/cmd/doc.go - Command implementations - cmd/gosqlx/internal/config/doc.go - CLI configuration - cmd/gosqlx/internal/output/doc.go - Output formatters - cmd/gosqlx/internal/validate/doc.go - Validation logic ### LSP Package - pkg/lsp/doc.go - LSP server (~600 lines) ## Enhanced Source File Documentation Updated 48 source files with comprehensive godoc comments including: - All exported types, functions, and methods - Thread-safety notes and concurrency patterns - Memory management and pool usage guidelines - Performance characteristics and benchmarks - Usage examples with best practices - Error handling patterns ## Documentation Standards Applied - Package overview sections with feature summaries - Architecture and design documentation - Quick start examples with working code - Thread-safety and memory management notes - Performance characteristics and benchmarks - Related packages and further reading sections - v1.6.0 feature coverage (LATERAL JOIN, JSON operators, etc.) ## Quality Verification - All tests pass with race detection (go test -race ./...) - No lint issues (golangci-lint run) - Code properly formatted (go fmt ./...) - No vet issues (go vet ./...) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * docs: update roadmap to reflect v1.6.0 progress Updated the README.md roadmap section to accurately reflect project progress: ## Completed Phases - Phase 1 (v1.1.0): JOIN Support ✅ - Phase 2 (v1.2.0): CTEs & Set Operations ✅ - Phase 2.5 (v1.3.0-v1.4.0): Window Functions, MERGE, Grouping Sets ✅ - Phase 3 (v1.5.0-v1.6.0): PostgreSQL Extensions, LSP, Linter ✅ ## Updated Future Phases - Phase 4 (v1.7.0): MySQL & SQL Server Dialects 🚧 - Phase 5 (v2.0.0): Query Intelligence & Optimization 📋 - Phase 6 (v2.1.0): Schema Awareness & Validation 📋 - Future Considerations: Stored Procedures, Triggers, PL/pgSQL, WASM 🔮 Added summary table at top for quick status overview and detailed feature lists for each completed phase showing actual accomplishments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Ajit Pratap Singh <ajitpratapsingh@Ajits-Mac-mini.local> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d4d5746 commit 0ac1a90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+25070
-1567
lines changed

CLAUDE.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
GoSQLX is a **production-ready**, **race-free**, high-performance SQL parsing SDK for Go that provides lexing, parsing, and AST generation with zero-copy optimizations. The library is designed for enterprise use with comprehensive object pooling for memory efficiency.
88

9+
**Requirements**: Go 1.24+
10+
11+
912
### **Production Status**: ✅ **VALIDATED FOR PRODUCTION DEPLOYMENT** (v1.6.0+)
1013
- **Thread Safety**: Confirmed race-free through comprehensive concurrent testing
1114
- **Performance**: 1.38M+ operations/second sustained, up to 1.5M peak with memory-efficient object pooling
@@ -27,6 +30,7 @@ GoSQLX is a **production-ready**, **race-free**, high-performance SQL parsing SD
2730
- **Errors** (`pkg/errors/`): Structured error handling system with error codes and position tracking
2831
- **Metrics** (`pkg/metrics/`): Production performance monitoring and observability
2932
- **Security** (`pkg/sql/security/`): SQL injection detection with pattern scanning and severity classification
33+
- **Linter** (`pkg/linter/`): SQL linting engine with 10 built-in rules (L001-L010) for style enforcement
3034
- **CLI** (`cmd/gosqlx/`): Production-ready command-line tool for SQL validation, formatting, and analysis
3135
- **LSP** (`pkg/lsp/`): Language Server Protocol server for IDE integration (diagnostics, hover, completion, formatting)
3236

@@ -42,7 +46,7 @@ The codebase uses extensive object pooling for performance optimization:
4246
### Token Processing Flow
4347

4448
1. **Input**: Raw SQL bytes → `tokenizer.Tokenize()``[]models.TokenWithSpan`
45-
2. **Conversion**: Token conversion → `parser.convertTokens()``[]token.Token`
49+
2. **Conversion**: Token conversion → `parser.ConvertTokensForParser()``[]token.Token`
4650
3. **Parsing**: Parser consumption → `parser.Parse()``*ast.AST`
4751
4. **Cleanup**: Release pooled objects back to pools when done
4852

@@ -129,6 +133,14 @@ task check
129133
task test:race
130134
```
131135

136+
### Pre-commit Hooks
137+
The repository has pre-commit hooks that automatically run on every commit:
138+
1. `go fmt` - Code formatting check
139+
2. `go vet` - Static analysis
140+
3. `go test -short` - Short test suite
141+
142+
If a commit fails pre-commit checks, fix the issues and retry the commit.
143+
132144
### Security
133145
```bash
134146
# Run security vulnerability scan
@@ -181,6 +193,14 @@ go run ./examples/cmd/example.go
181193
go install github.com/ajitpratap0/GoSQLX/cmd/gosqlx@latest
182194
```
183195

196+
### Additional Documentation
197+
- `docs/GETTING_STARTED.md` - Quick start guide for new users
198+
- `docs/USAGE_GUIDE.md` - Comprehensive usage guide
199+
- `docs/LSP_GUIDE.md` - Complete LSP server documentation and IDE integration
200+
- `docs/LINTING_RULES.md` - All 10 linting rules (L001-L010) reference
201+
- `docs/CONFIGURATION.md` - Configuration file (.gosqlx.yml) guide
202+
- `docs/SQL_COMPATIBILITY.md` - SQL dialect compatibility matrix
203+
184204
## Key Implementation Details
185205

186206
### Memory Management (CRITICAL FOR PERFORMANCE)
@@ -294,6 +314,12 @@ Tests are organized with comprehensive coverage (30+ test files, 6 benchmark fil
294314

295315
### Component-Specific Testing
296316
```bash
317+
# Run a single test by name
318+
go test -v -run TestSpecificTestName ./pkg/sql/parser/
319+
320+
# Run tests matching a pattern
321+
go test -v -run "TestParser_Window.*" ./pkg/sql/parser/
322+
297323
# Core library testing with race detection
298324
go test -race ./pkg/sql/tokenizer/ -v
299325
go test -race ./pkg/sql/parser/ -v
@@ -602,6 +628,32 @@ JOIN posts p USING (user_id)
602628
WHERE p.published = true;
603629
```
604630

631+
### PostgreSQL Extensions (v1.6.0) - Complete ✅
632+
```sql
633+
-- LATERAL JOIN - correlated subqueries in FROM clause
634+
SELECT u.name, r.order_date FROM users u,
635+
LATERAL (SELECT * FROM orders WHERE user_id = u.id ORDER BY order_date DESC LIMIT 3) r;
636+
637+
-- JSON/JSONB Operators (->/->>/#>/#>>/@>/<@/?/?|/?&/#-)
638+
SELECT data->>'name' AS name, data->'address'->>'city' AS city FROM users;
639+
SELECT * FROM products WHERE attributes @> '{"color": "red"}';
640+
SELECT * FROM users WHERE profile ? 'email';
641+
642+
-- DISTINCT ON - PostgreSQL-specific row selection
643+
SELECT DISTINCT ON (dept_id) dept_id, name, salary
644+
FROM employees ORDER BY dept_id, salary DESC;
645+
646+
-- FILTER Clause - conditional aggregation (SQL:2003)
647+
SELECT COUNT(*) FILTER (WHERE status = 'active') AS active_count,
648+
SUM(amount) FILTER (WHERE type = 'credit') AS total_credits
649+
FROM transactions;
650+
651+
-- RETURNING Clause - return modified rows
652+
INSERT INTO users (name, email) VALUES ('John', 'john@example.com') RETURNING id, created_at;
653+
UPDATE products SET price = price * 1.1 WHERE category = 'Electronics' RETURNING id, price;
654+
DELETE FROM sessions WHERE expired_at < NOW() RETURNING user_id;
655+
```
656+
605657
### DDL and DML Operations - Complete ✅
606658
```sql
607659
-- Table operations

README.md

Lines changed: 74 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -913,36 +913,89 @@ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guid
913913

914914
## Roadmap
915915

916-
### Phase 1: Core SQL Enhancements (Q1 2025) - v1.1.0 ✅
916+
<div align="center">
917+
918+
| Phase | Version | Status | Highlights |
919+
|-------|---------|--------|------------|
920+
| **Phase 1** | v1.1.0 | ✅ Complete | JOIN Support |
921+
| **Phase 2** | v1.2.0 | ✅ Complete | CTEs & Set Operations |
922+
| **Phase 2.5** | v1.3.0-v1.4.0 | ✅ Complete | Window Functions, MERGE, Grouping Sets |
923+
| **Phase 3** | v1.5.0-v1.6.0 | ✅ Complete | PostgreSQL Extensions, LSP, Linter |
924+
| **Phase 4** | v1.7.0 | 🚧 In Progress | MySQL & SQL Server Dialects |
925+
| **Phase 5** | v2.0.0 | 📋 Planned | Query Intelligence & Optimization |
926+
| **Phase 6** | v2.1.0 | 📋 Planned | Schema Awareness & Validation |
927+
928+
</div>
929+
930+
### Phase 1: Core SQL Enhancements - v1.1.0 ✅
917931
-**Complete JOIN support** (INNER/LEFT/RIGHT/FULL OUTER/CROSS/NATURAL)
918-
-**Proper join tree logic** with left-associative relationships
919-
-**USING clause parsing** (single-column, multi-column planned for Phase 2)
932+
-**Proper join tree logic** with left-associative relationships
933+
-**USING clause parsing** for single and multi-column joins
920934
-**Enhanced error handling** with contextual JOIN error messages
921-
-**Comprehensive test coverage** (15+ JOIN scenarios including error cases)
922-
- 🏗️ **CTE foundation laid** (AST structures, tokens, parser integration points)
935+
-**Comprehensive test coverage** (15+ JOIN scenarios)
923936

924-
### Phase 2: CTE & Advanced Features (Q1 2025) - v1.2.0 ✅
937+
### Phase 2: CTE & Set Operations - v1.2.0 ✅
925938
-**Common Table Expressions (CTEs)** with RECURSIVE support
926939
-**Set operations** (UNION/EXCEPT/INTERSECT with ALL modifier)
927940
-**Left-associative set operation parsing**
928941
-**CTE column specifications** and multiple CTE definitions
929-
-**Integration of CTEs with set operations**
930-
-**Enhanced error handling** with contextual messages
931942
-**~70% SQL-92 compliance** achieved
932943

933-
### Phase 3: Dialect Specialization (Q1 2025) - v2.0.0
934-
- 📋 PostgreSQL arrays, JSONB, custom types
935-
- 📋 MySQL-specific syntax and functions
936-
- 📋 SQL Server T-SQL extensions
937-
- 📋 Multi-dialect parser with auto-detection
938-
939-
### Phase 4: Intelligence Layer (Q2 2025) - v2.1.0
940-
- 📋 Query optimization suggestions
941-
- 📋 Security vulnerability detection
942-
- 📋 Performance analysis and hints
943-
- 📋 Schema validation
944-
945-
See [ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed system design
944+
### Phase 2.5: Window Functions & Advanced SQL - v1.3.0-v1.4.0 ✅
945+
-**Window Functions** - Complete SQL-99 support (ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, LEAD, FIRST_VALUE, LAST_VALUE)
946+
-**Window Frames** - ROWS/RANGE with PRECEDING/FOLLOWING/CURRENT ROW
947+
-**MERGE Statements** - SQL:2003 F312 with WHEN MATCHED/NOT MATCHED clauses
948+
-**GROUPING SETS, ROLLUP, CUBE** - SQL-99 T431 advanced grouping
949+
-**Materialized Views** - CREATE, REFRESH, DROP support
950+
-**Expression Operators** - BETWEEN, IN, LIKE, IS NULL, NULLS FIRST/LAST
951+
-**~75% SQL-99 compliance** achieved
952+
953+
### Phase 3: PostgreSQL Extensions & Developer Tools - v1.5.0-v1.6.0 ✅
954+
-**LATERAL JOIN** - Correlated subqueries in FROM clause
955+
-**JSON/JSONB Operators** - All 10 operators (`->`, `->>`, `#>`, `#>>`, `@>`, `<@`, `?`, `?|`, `?&`, `#-`)
956+
-**DISTINCT ON** - PostgreSQL-specific row selection
957+
-**FILTER Clause** - Conditional aggregation (SQL:2003 T612)
958+
-**Aggregate ORDER BY** - ORDER BY inside STRING_AGG, ARRAY_AGG, etc.
959+
-**RETURNING Clause** - Return modified rows from INSERT/UPDATE/DELETE
960+
-**LSP Server** - Full Language Server Protocol with diagnostics, completion, hover, formatting
961+
-**Linter Engine** - 10 built-in rules (L001-L010) with auto-fix
962+
-**Security Scanner** - SQL injection detection with severity classification
963+
-**Structured Errors** - Error codes E1001-E3004 with position tracking
964+
-**CLI Enhancements** - Pipeline support, stdin detection, cross-platform
965+
-**~80-85% SQL-99 compliance** achieved
966+
967+
### Phase 4: MySQL & SQL Server Dialects - v1.7.0 🚧
968+
- 🚧 **MySQL Extensions** - AUTO_INCREMENT, REPLACE INTO, ON DUPLICATE KEY
969+
- 📋 **MySQL Functions** - DATE_FORMAT, IFNULL, GROUP_CONCAT specifics
970+
- 📋 **SQL Server T-SQL** - TOP, OFFSET-FETCH, OUTPUT clause
971+
- 📋 **SQL Server Functions** - ISNULL, CONVERT, DATEPART specifics
972+
- 📋 **Dialect Auto-Detection** - Automatic syntax detection from queries
973+
- 📋 **Cross-Dialect Translation** - Convert between dialect syntaxes
974+
975+
### Phase 5: Query Intelligence & Optimization - v2.0.0 📋
976+
- 📋 **Query Cost Estimation** - Complexity analysis and scoring
977+
- 📋 **Index Recommendations** - Suggest indexes based on query patterns
978+
- 📋 **Join Order Optimization** - Recommend optimal join sequences
979+
- 📋 **Subquery Optimization** - Detect and suggest subquery improvements
980+
- 📋 **N+1 Query Detection** - Identify inefficient query patterns
981+
- 📋 **Performance Hints** - Actionable optimization suggestions
982+
983+
### Phase 6: Schema Awareness & Validation - v2.1.0 📋
984+
- 📋 **Schema Definition Parsing** - Full DDL understanding
985+
- 📋 **Type Checking** - Validate column types in expressions
986+
- 📋 **Foreign Key Validation** - Verify relationship integrity
987+
- 📋 **Constraint Checking** - NOT NULL, UNIQUE, CHECK validation
988+
- 📋 **Schema Diff** - Compare and generate migration scripts
989+
- 📋 **Entity-Relationship Extraction** - Generate ER diagrams from DDL
990+
991+
### Future Considerations 🔮
992+
- 📋 **Stored Procedures** - CREATE PROCEDURE/FUNCTION parsing
993+
- 📋 **Triggers** - CREATE TRIGGER support
994+
- 📋 **PL/pgSQL** - PostgreSQL procedural language
995+
- 📋 **Query Rewriting** - Automatic query transformation
996+
- 📋 **WASM Support** - Browser-based SQL parsing
997+
998+
See [ARCHITECTURE.md](docs/ARCHITECTURE.md) for detailed system design and [CHANGELOG.md](CHANGELOG.md) for version history
946999

9471000
## Community & Support
9481001

0 commit comments

Comments
 (0)