GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — docs: explain how to use the batch object by jotikrishna · Pull Request #4633 · sqlc-dev/sqlc ConversationProblemThe
#4631 reports exactly this: a reader cannot tell what to do with the returned batch object from the docs alone. SolutionAdd a Using the batch object section documenting the callback contract and Documented behaviour:
Everything stated is taken from the generated code itself - TestingThe repo's docs content contract is enforced by Baseline before the edit: the same test passed, so the change introduces no new contract violations. All anchor links in the new section resolve under the linter's Not run: the full end-to-end suite requires live PostgreSQL/MySQL instances via Docker, which I don't have available; the documentation change does not touch code paths, and the docs test above is the gate that covers it. ImpactReaders of the batch annotations can now use the returned batch object without reading sqlc's template source. The three existing sections keep their shape and gain one pointer line each. Fixes #4631
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsThe :batchexec, :batchmany and :batchone sections listed the batch object's methods but never said what the callback receives, what its int argument means, what Close does to statements that have not run yet, or when Close is even needed. Issue sqlc-dev#4631 reports exactly this: readers cannot tell what to do with the returned batch object. Add a 'Using the batch object' section that documents the callback contract and Close semantics, and point each batch annotation at it: - the callback is invoked once per queued statement, in order, and the int is the statement's 0-based position in the batch - a failing statement does not stop iteration; errors must be handled inside the callback - Close before or during iteration skips the remaining statements and delivers ErrBatchAlreadyClosed once per remaining statement - Close is called automatically when the iteration method returns, so a fully iterated batch needs no explicit Close The behaviour described is taken from the generated code itself (internal/codegen/golang/templates/pgx/batchCode.tmpl and the batch endtoend golden files), not paraphrased from other docs. Fixes sqlc-dev#4631
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ReviewersNo reviewsUh oh!
There was an error while loading. Please reload this page. AssigneesNo one assignedLabels
None yet
ProjectsMilestoneNo milestoneDevelopmentSuccessfully merging this pull request may close these issues. Documentation for batch object returned by :batch* annotations could be more clearUh oh!
There was an error while loading. Please reload this page. 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. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |