GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add tests for PR #4646 (:iter query annotation) by sgielen · Pull Request #4647 · sqlc-dev/sqlc

Conversation

@sgielen

@sgielen sgielen commented Oct 16, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

This is a stacked PR on top of #4646, which adds :iter. This PR contains further tests, to keep that PR lean and reviewable.

Because Github doesn't do stacked PRs across a fork, it looks like this PR also contains #4646's changes. In order to review this commit I'd advise to look at the individual commits:

  • 7f30b96
  • fcefbdc

This adds test coverage for :iter at the same level as the other query types: one small case of its own, plus an :iter query in the existing cases for each Go option that changes the generated method.

PostgreSQL

  • iter/postgresql/{stdlib,pgx/v5}: a struct result with a SQL comment, a scalar result with a parameter, and a DELETE … RETURNING, generated with emit_interface.
  • An :iter query in wrap_errors, prepared_queries and comment_godoc_db_argument.
  • invalid_queries_foo checks that :iter needs a RETURNING clause, like :one and :many.
  • The "missing query type" error now lists :iter.

MySQL and SQLite

  • An :iter query in wrap_errors (MySQL, SQLite), prepared_queries (MySQL) and sqlc_slice (MySQL).
  • TestIterAuthors in the SQLite authors example. It runs the stdlib template against a real database, like the PostgreSQL authors test in Add the :iter query annotation #4646 does for pgx: the query only runs once ranging starts, ranging a second time reports an error, break releases the connection, and a cancelled query's error comes back from the returned func.

One template change. The sqlc.slice branch of the shared queryCodeStdExec helper started its output with a newline. Every other command calls the helper right after an opening {, so the newline never showed. :iter calls it after a statement, where it left a blank line. The branch now trims it, and no other golden changes.

The goldens of the existing cases only gain lines: the :iter method, its imports, and for prepared_queries the prepared statement.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sgielen and others added 4 commits October 16, 2026 18:57
@sgielen
Add the :iter query annotation
289098b
A :iter query generates a method returning an iter.Seq over the query's
rows, plus a function returning the query's error once the loop is done.
The PostgreSQL authors example shows its use.
@sgielen
Add documentation for the :iter query annotation
138b1c9
@sgielen @claude
Test :iter end to end with PostgreSQL
7f30b96
A case of its own for the stdlib and pgx templates, and an :iter query
in the cases for wrap_errors, emit_prepared_queries and
emit_methods_with_db_argument, as the other query types have.
invalid_queries_foo covers :iter without a RETURNING clause, and the
"missing query type" error now lists :iter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sgielen @claude
Test :iter with MySQL and SQLite
fcefbdc
An :iter query in the wrap_errors, emit_prepared_queries and sqlc_slice
cases for MySQL and SQLite, and a runtime test in the SQLite authors
example, covering the stdlib template against a live database.

queryCodeStdExec no longer starts with a newline when it rewrites a
query for sqlc.slice, which left a blank line inside :iter methods.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sgielen sgielen mentioned this pull request Oct 16, 2026
Add the :iter query annotation #4646
Open
@sgielen
sgielen marked this pull request as ready for review October 16, 2026 17:56
@sgielen sgielen changed the title Test the :iter query annotation Add tests for PR #4646 (:iter query annotation) Oct 16, 2026
@Jille Jille mentioned this pull request Oct 17, 2026
add :stream keyword` #4464
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@sgielen
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.