-
Notifications
You must be signed in to change notification settings - Fork 5
feat: improve AST test coverage to 80%+ and add parser position tracking #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add TestStatementNodeMarkers: tests all statementNode() marker methods - Add TestExpressionNodeMarkers: tests all expressionNode() marker methods - Add TestTokenLiteralMethods: tests TokenLiteral() for 60+ node types - Add TestChildrenMethods: comprehensive tests for Children() with all branches - Add tests for SELECT, INSERT, UPDATE, DELETE statement Children() - Add tests for ALTER statement operations and Children() - Add tests for BinaryOperator, IndexType, NullsDistinctOption String() - Add tests for IndexOption.String() with all option types Coverage improved from 60.7% to 70.1% 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
This commit addresses two key improvements:
1. AST Test Coverage (60.7% → 80.5%)
- Add comprehensive tests for DateTimeField.String() covering all 44+ cases
- Include plural forms (Years, Months, Days, Hours, Minutes, Seconds, etc.)
- Cover timezone fields (TimezoneAbbr, TimezoneHour, TimezoneMinute, TimezoneRegion)
- Test default/unknown case for complete branch coverage
2. Parser Position Tracking Infrastructure
- Add `positions []TokenPosition` field to Parser struct for source mapping
- Add `currentLocation()` helper method for accurate error locations
- Add `currentEndLocation()` helper for end position access
- Add `ParseWithPositions(*ConversionResult)` method for position-aware parsing
- Update `Reset()` to clear position state
3. Fix Position Tracking TODOs
- Replace `models.Location{}` with `p.currentLocation()` in:
- grouping.go: ROLLUP/CUBE empty list errors
- select.go: Column def, constraint, JOIN, and set operation errors
- parser.go: expectedError() and ParseContext error handling
The position tracking infrastructure enables accurate line/column information
in error messages when using ParseWithPositions() with ConversionResult from
the token converter. Backward compatibility is maintained for existing Parse().
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
|
Claude finished @ajitpratap0's task —— View job ✅ Code Review Complete🎯 SummaryThis is a high-quality PR that successfully improves AST test coverage and adds essential parser position tracking infrastructure. The changes are well-designed, backward compatible, and follow GoSQLX's established patterns. Key Achievements
📊 Detailed Review🟢 Excellent Test Coverage ImprovementFiles: Strengths:
Code Quality: ⭐⭐⭐⭐⭐
🟢 Robust Position Tracking ImplementationFiles: Strengths:
Architecture Excellence: // Clean separation of concerns
type ConversionResult struct {
Tokens []token.Token
PositionMapping []TokenPosition // Maps parser token index to original position
}
// Safe position access with bounds checking
func (p *Parser) currentLocation() models.Location {
if p.positions == nil || p.currentPos >= len(p.positions) {
return models.Location{}
}
return p.positions[p.currentPos].Start
}🟢 Strategic TODO ResolutionFiles: Excellent approach:
🔍 Security & Performance Analysis🛡️ Security: ✅ No Concerns
⚡ Performance: ✅ Optimized
🐛 Bug Analysis: ✅ None FoundCareful review reveals:
📈 Code Quality: ⭐⭐⭐⭐⭐Excellent Patterns✅ Repository Alignment: Follows CLAUDE.md guidelines perfectly Minor Suggestions (Optional Enhancements)
🔄 Backward Compatibility: ✅ PerfectThe PR maintains 100% backward compatibility:
✅ Recommendations
🎯 Final AssessmentThis PR demonstrates excellent software engineering practices:
Verdict: ✅ APPROVED - Ready for merge after race detection validation |
Remove unused currentEndLocation() method to fix golangci-lint error. The method was added for completeness but is not currently used. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @ajitpratap0's task —— View job ✅ Pull Request Review Complete🎯 SummaryThis is a high-quality PR that successfully improves AST test coverage and adds essential parser position tracking infrastructure. The changes are well-designed, backward compatible, and follow GoSQLX's established patterns. Key Achievements
📊 Detailed Review🟢 Excellent Test Coverage ImprovementFiles: Strengths:
Code Quality: ⭐⭐⭐⭐⭐
🟢 Robust Position Tracking ImplementationFiles: Strengths:
Architecture Excellence: // Clean separation of concerns
type ConversionResult struct {
Tokens []token.Token
PositionMapping []TokenPosition // Maps parser token index to original position
}
// Safe position access with bounds checking
func (p *Parser) currentLocation() models.Location {
if p.positions == nil || p.currentPos >= len(p.positions) {
return models.Location{}
}
return p.positions[p.currentPos].Start
}🟢 Strategic TODO ResolutionFiles: Excellent approach:
🔍 Security & Performance Analysis🛡️ Security: ✅ No Concerns
⚡ Performance: ✅ Optimized
🐛 Bug Analysis: ✅ None FoundCareful review reveals:
📈 Code Quality: ⭐⭐⭐⭐⭐Excellent Patterns✅ Repository Alignment: Follows CLAUDE.md guidelines perfectly Minor Suggestions (Optional Enhancements)
🔄 Backward Compatibility: ✅ PerfectThe PR maintains 100% backward compatibility:
✅ Recommendations
🎯 Final AssessmentThis PR demonstrates excellent software engineering practices:
Verdict: ✅ APPROVED - Ready for merge after race detection validation | |
Summary
This PR addresses two key improvements to the GoSQLX codebase:
1. AST Test Coverage Improvement (60.7% → 80.5%)
DateTimeField.String()covering all 44+ enum cases:Year,Month,Day,Hour,Minute,SecondYears,Months,Days,Hours,Minutes,Seconds,Weeks,Milliseconds,Microseconds,NanosecondsDate,Datetime,Time,Quarter,WeekCentury,Decade,Dow,Doy,Epoch,Isodow,IsoWeek,Isoyear,JulianMillenium,MillenniumTimezone,TimezoneAbbr,TimezoneHour,TimezoneMinute,TimezoneRegionNoDateTime, defaultUNKNOWNcase2. Parser Position Tracking Infrastructure
Added infrastructure for accurate error locations in parser error messages:
New Parser Fields & Methods
positions []TokenPosition- Stores source position mapping from token convertercurrentLocation() models.Location- Returns current token's source locationcurrentEndLocation() models.Location- Returns current token's end locationParseWithPositions(*ConversionResult) (*ast.AST, error)- New parsing method with position trackingFixed Position Tracking TODOs
Replaced
models.Location{}placeholders withp.currentLocation()in:expectedError()method andParseContexterror handlingHow Position Tracking Works
Files Changed
pkg/sql/ast/value_test.gopkg/sql/ast/coverage_test.gopkg/sql/parser/parser.gopkg/sql/parser/grouping.gopkg/sql/parser/select.goTest plan
go test -race ./...)Backward Compatibility
✅ Fully backward compatible - The existing
Parse()method continues to work without positions. The newParseWithPositions()method is additive.🤖 Generated with Claude Code