-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Parser Enhancements Batch 6 - PostgreSQL UPSERT, Type Casting & Parameters #196
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
… Parameters Implements three parser enhancements for PostgreSQL compatibility: #195: Positional Parameters ($1, $2, etc.) - Tokenizer handles $ followed by digits as placeholders - Returns TokenTypePlaceholder with value like "$1" #188: PostgreSQL Type Casting (::) - parseJSONExpression() handles :: operator - Added parseDataType() and isDataTypeKeyword() helpers - Supports parameterized types (VARCHAR(100), NUMERIC(10,2)) - Supports array type suffix (INTEGER[]) - Reuses existing CastExpression AST node #193: INSERT ON CONFLICT (UPSERT) - Added parseOnConflictClause() function - Supports conflict target: (column_list) or ON CONSTRAINT name - Supports DO NOTHING action - Supports DO UPDATE SET with EXCLUDED pseudo-table - Supports optional WHERE clause in DO UPDATE - Works with RETURNING clause All tests pass with race detection (go test -race ./pkg/...). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude finished @ajitpratap0's task —— View job Code Review Complete ✅I've thoroughly reviewed this PR implementing PostgreSQL parser enhancements. Here's my comprehensive feedback: Overall AssessmentThis is a well-implemented PR that adds significant PostgreSQL compatibility features. The code quality is good and follows project patterns consistently. ✅ Strengths1. Tokenizer Implementation (Positional Parameters)
2. Type Casting Implementation
3. ON CONFLICT Implementation
4. Test Coverage
|
Addresses review comments from Claude bot:
1. Memory Management: Replace string concatenation with strings.Builder
in parseDataType() for efficient type string construction
2. Error Context: Include actual token value in error messages
(e.g., "expected numeric type parameter, got 'foo'")
3. Token Type Consistency: Add isNumericLiteral() helper that uses
token type constants instead of string literals ("INT", "NUMBER")
4. Dollar-Quoted Strings: Add comprehensive TODO comment explaining
PostgreSQL dollar-quoted string syntax ($tag$...$tag$) and linking
to issue #189 for future implementation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
Claude finished @ajitpratap0's task —— View job Pull Request Review - PostgreSQL Parser EnhancementsReviewing PR #196 that implements PostgreSQL compatibility features:
Todo List
Code Review Summary ✅This PR implements solid PostgreSQL compatibility features with good adherence to the existing codebase patterns. The implementation is well-structured and follows the project's architectural conventions. ✅ Strengths1. Positional Parameters Implementation
2. Type Casting Implementation
3. ON CONFLICT Implementation
4. Test Coverage
|
Summary
This PR implements three parser enhancements for improved PostgreSQL compatibility:
Issue #195: Positional Parameters ($1, $2, etc.)
$followed by digits as placeholders (e.g.,$1,$10,$999)TokenTypePlaceholderwith value like"$1"Issue #188: PostgreSQL Type Casting (::)
parseJSONExpression()to handle::type cast operatorparseDataType()helper for parsing SQL data typesisDataTypeKeyword()to recognize SQL type keywordsVARCHAR(100),NUMERIC(10,2)INTEGER[]CastExpressionAST nodeIssue #193: INSERT ON CONFLICT (UPSERT)
parseOnConflictClause()function in dml.goON CONFLICT (id, email)ON CONFLICT ON CONSTRAINT users_pkeyDO NOTHINGDO UPDATE SET col = expr, ...with EXCLUDED pseudo-table supportWHEREclause inDO UPDATERETURNINGclauseTest plan
go test -race ./pkg/...)Examples
🤖 Generated with Claude Code