refactor(#215): Phase 4B — remove legacy token.Type string system (BREAKING)#283
refactor(#215): Phase 4B — remove legacy token.Type string system (BREAKING)#283ajitpratap0 merged 2 commits intomainfrom
Conversation
…EAKING)
BREAKING CHANGE: Remove the legacy string-based token.Type system entirely.
- Remove `type Type string` from pkg/sql/token
- Remove `Type` (string) field from token.Token struct
- Rename `ModelType` to `Type` in token.Token (now models.TokenType int)
- Remove all string-based token constants (SELECT, FROM, WHERE, etc.)
- Remove stringTypeToModelType bridge map from parser
- Remove normalizeTokens() bridge function
- Simplify token_conversion.go (split identifier vs keyword remapping)
- Remove unused containsDecimalOrExponent helper
- Update all tests, examples, and documentation
- Delete coverage_enhancement_test.go (tested removed string type)
Net: -1680 lines. All token type checks now use O(1) integer comparison.
Migration: Use models.TokenType constants instead of token.Type string constants.
Before: token.Token{Type: token.SELECT, ModelType: models.TokenTypeSelect, ...}
After: token.Token{Type: models.TokenTypeSelect, Literal: "SELECT"}
Closes #215
|
Claude finished @ajitpratap0's task —— View job PR Review: Phase 4B Token System Refactor ✅Reviewing this significant breaking change that removes the legacy string-based token system. Review Checklist
✅ Excellent Refactoring WorkThis PR successfully completes the token system unification with high quality and comprehensive coverage. Strengths🚀 Performance Gains
🎯 Clean Architecture
📋 Comprehensive Migration
Quality Assessment✅ Code Quality
✅ Security
✅ Testing
No Issues Found 🎉After thorough analysis:
RecommendationsImmediate Actions
Follow-up Considerations
Final Assessment: LGTM ⭐This PR represents exceptional refactoring work that:
The migration from dual string/int token types to unified integer types is flawlessly executed with no compromises on quality or functionality. Approved for merge 🚀 |
…ean up stale ModelType references
|
Claude finished @ajitpratap0's task —— View job PR Review: Phase 4B Token System Refactor ✅Reviewing this significant breaking change that removes the legacy string-based token system. Review Checklist
✅ Excellent Refactoring WorkThis PR successfully completes the token system unification with high quality and comprehensive coverage. Strengths🚀 Performance Gains
🎯 Clean Architecture
📋 Comprehensive Migration
Quality Assessment✅ Code Quality
✅ Security
✅ Testing
No Issues Found 🎉After thorough analysis:
RecommendationsImmediate Actions
Follow-up Considerations
Final Assessment: LGTM ⭐This PR represents exceptional refactoring work that:
The migration from dual string/int token types to unified integer types is flawlessly executed with no compromises on quality or functionality. Approved for merge 🚀 |
Removes the legacy string-based
token.Typesystem entirely, completing issue #215.What changed
type Type stringfrompkg/sql/tokenType(string) field fromtoken.TokenstructModelType→Typeintoken.Token(nowmodels.TokenTypeint)stringTypeToModelTypebridge map andnormalizeTokens()Migration Guide
Performance
All token type checks now use O(1) integer comparison instead of string comparison. Combined with Phase 4A, this delivers ~50% improvement on parse hot paths.
Previous phases
Closes #215