[WIP] Add pgx helpers: PgxSession interface and CopyToTempTable generic#3759
[WIP] Add pgx helpers: PgxSession interface and CopyToTempTable generic#3759mstaeble wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mstaeble The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
WalkthroughA reusable pgx temporary-table COPY helper was added with typed column descriptors, validation, contextual errors, and cleanup. The test ownership loader now uses the helper instead of managing temporary-table creation and row copying directly. ChangesTemporary-table bulk loading
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Loader
participant CopyToTempTable
participant PostgreSQL
Loader->>CopyToTempTable: Provide TestOwnership rows and column descriptors
CopyToTempTable->>PostgreSQL: Create temporary table
CopyToTempTable->>PostgreSQL: Bulk COPY rows
CopyToTempTable-->>Loader: Return cleanup function
Loader->>PostgreSQL: Drop temporary table
Possibly related PRs
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 2 warnings)
✅ Passed checks (18 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 26 minutes. |
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 58 minutes. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
aa7e493 to
5d09d76
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/db/pgx.go`:
- Around line 49-54: Validate every column name with validIdentifier before
constructing colDefs or createSQL, and return an appropriate error for any
invalid identifier. Since DDL identifiers and type definitions cannot use
placeholders, also validate c.Type using the repository’s established PostgreSQL
type allow-list or permissive type-validation rule before interpolation; keep
tempTable validation and the existing CREATE TEMP TABLE flow unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: b3c0fa4d-00f3-42fe-b49d-4ad34b202b2b
📒 Files selected for processing (2)
pkg/dataloader/testownershiploader/testownershiploader.gopkg/db/pgx.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/dataloader/testownershiploader/testownershiploader.go
Introduces shared pgx utilities in pkg/db/pgx.go: - PgxQuerier: interface satisfied by both *pgx.Conn and pgx.Tx, enabling functions to work with either raw connections or transactions. - TempColumn[T]: typed column definition binding a column name, SQL type, and value extractor together so callers cannot have out-of-order columns. - CopyToTempTable[T]: creates a temp table, COPYs rows into it via the COPY protocol, and returns a cleanup function. Cleans up automatically on COPY failure. Moves the existing CopyFrom helper from copyfrom.go into the same file. Converts testownershiploader to use CopyToTempTable, replacing manual CREATE TEMP TABLE + CopyFrom + DROP TABLE boilerplate. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5d09d76 to
8527802
Compare
Summary
pkg/db/pgx.go:PgxSession: interface satisfied by both*pgx.Connandpgx.Tx, enabling functions to work with either raw connections or transactionsTempColumn[T]: typed column definition binding a column name, SQL type, and value extractor so callers cannot have out-of-order columnsCopyToTempTable[T]: creates a temp table, COPYs rows into it via the COPY protocol, and returns a cleanup function. Cleans up automatically on COPY failure.testownershiploaderto useCopyToTempTable, replacing manual CREATE TEMP TABLE + CopyFrom + DROP TABLE boilerplateTest plan
make lintpasses (0 issues)make testpassesmake e2epasses (108 tests, 0 failures)🤖 Generated with Claude Code
Summary by CodeRabbit