feat(#249): Dialect mode engine (Phase 1)#315
Conversation
- Add Dialect field and SetDialect/NewWithDialect to Tokenizer - Add WithDialect ParserOption and Dialect() getter to Parser - Add ParseWithDialect/ValidateWithDialect convenience functions - Wire --dialect flag through CLI validator to tokenizer and parser - Add comprehensive dialect tests (flow, MySQL/PostgreSQL keywords, defaults) - Backward compatible: default behavior unchanged (PostgreSQL dialect)
|
Claude finished @ajitpratap0's task —— View job PR Review: Dialect Mode Engine (Phase 1) ✅Comprehensive review of the dialect mode implementation across tokenizer, parser, CLI, and tests. Review Progress
🎯 Review SummaryThis is a well-implemented Phase 1 that successfully threads SQL dialect support through the entire parsing pipeline. The implementation follows GoSQLX patterns and maintains excellent backward compatibility. ✅ Strengths1. Architecture & Design
2. Memory Management ⭐
3. Thread Safety
4. Test Coverage
5. CLI Integration
🔧 Implementation QualityTokenizer Changes (
|
|
Claude finished @ajitpratap0's task —— View job PR Review: Dialect Mode Engine (Phase 1) ✅Comprehensive review of the dialect mode implementation across tokenizer, parser, CLI, and tests. Review Progress
🎯 Review SummaryThis is a well-implemented Phase 1 that successfully threads SQL dialect support through the entire parsing pipeline. The implementation follows GoSQLX patterns and maintains excellent backward compatibility. ✅ Strengths1. Architecture & Design
2. Memory Management ⭐
3. Thread Safety
4. Test Coverage
5. CLI Integration
🔧 Implementation QualityTokenizer Changes (
|
Summary
Phase 1 of dialect mode support (#249): core plumbing to thread SQL dialect through the tokenizer and parser without adding any dialect-specific parsing logic.
Changes
Tokenizer (
pkg/sql/tokenizer/tokenizer.go)dialectfield toTokenizerstructNewWithDialect(dialect)constructor — creates tokenizer with dialect-aware keywordsSetDialect(dialect)— reconfigure pooled tokenizer for a different dialectDialect()getterParser (
pkg/sql/parser/parser.go)dialectfield toParserstructWithDialect(dialect)parser optionDialect()getter (defaults topostgresql)Public API (
pkg/sql/parser/validate.go)ParseWithDialect(sql, dialect)— convenience functionValidateWithDialect(sql, dialect)— convenience functionParseBytesWithDialect/ValidateBytesWithDialect— byte variantsCLI Wiring (
cmd/gosqlx/cmd/)validate.go:--dialectflag flows toValidateWithDialectfor inline SQLvalidator.go:SetDialectcalled on pooled tokenizer;WithDialectpassed to parserTests (
pkg/sql/parser/dialect_test.go)ParseWithDialect/ValidateWithDialectend-to-endBackward Compatibility
All defaults remain PostgreSQL. Existing code paths unchanged.
Closes phase 1 of #249.