Repository navigation
[yumin-xia] feat(wicked): generate opt-in Each readers - #24
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Generated
:manymethods collect every row before returning. Add opt-in-- -- each: truefor SELECT reads so callers can validate, filter, aggregate, stream or bound their own collection without handwritten SQL plumbing.The annotation generates
XxxEach(ctx, params, visit) errorbeside the existing slice method. The typed visitor receives the effective query context and returns(more bool, err error): true continues, false stops consumption, and a non-nil error remains primary after cleanup.Architecture and Key Decisions
Querierinterface retain their exact signatures and behavior. Optional companions use a separateEachQuerierinterface.CI also uncovered a pre-existing Go 1.26.10 standard-library vulnerability (GO-2026-6859). The build/release minimum and existing CI pins are updated to the Go 1.26.11 security patch; library dependencies and generated APIs are unchanged.
Risks and Remaining Work
Callbacks hold the connection and must respect the query context. Each shares the SQL operation/CountIntent label with the slice method; runtimes that measure through rows.Close include callback time, and explicit abort may appear as a context-canceled DB error under that label. Syntactic SELECT validation cannot prove function side-effect freedom. Each does not bound the allocation required to receive/decode the current row; SQL-level single-value protections and application policies remain explicit. Downstream adoption follows a generator release.
Breaking Changes
None. Without opt-in, eight downstream input snapshots regenerate byte-identically: 1,031 Go files, zero differences. Existing cache/invalidation, timeout and Dump/Load output is unchanged.
Database Migrations
None.
Verification
GOWORK=off GOMAXPROCS=2 go build -p=2 ./...andgo test -p=2 -count=1 ./internal/cmd ./internal/codegen/wicked ./internal/compiler ./internal/sql/astutils ./internal/pluginpassed.go build -p=2 ./...andgo test -race -p=2 -count=1 ./wicked_compat/go ./wicked_many/go ./wicked_each/gopassed.buf lintandgit diff --checkpassed.e9467fcpasses all active CI checks: full repository tests, bookstore compatibility/runtime contracts, six platform builds, protocol checks and govulncheck (10 success; 3 conditional language jobs skipped).Merge Order
None. No runtime release dependency.
Related PRs
None. Implementation and review evidence:
docs/changelogs/2026-11-11-add-many-each.md.Independent Claude Code review explicitly endorses the design and accepts the complete implementation diff. Both agents reviewed final content; no actionable finding remains. The reviewer independently executed generator/fixture/runtime and selected consumer checks across implementation rounds, and inspected the author's broader PG/race/runtime-version/consumer evidence. This reconfirmation and its scope are recorded in the changelog.