Skip to content

The pool's With and WithQueries return a PoolConn - #53

Merged
djthorpe merged 1 commit into
masterfrom
djt/1119/poolconn-with
Nov 19, 2026
Merged

djthorpe merged 1 commit into
masterfrom
djt/1119/poolconn-with

Conversation

@djthorpe

@djthorpe djthorpe commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

The pool's With and WithQueries now return a *poolconn rather than the embedded *conn. So the result is a sqlite.PoolConn, which can ping and close the pool:

pool := db.WithQueries(queries).(sqlite.PoolConn)

A type that keeps only its connection, bound to its queries, no longer needs to keep the pool beside it just to close it.

  • Signatures: unchanged. They still return sqlite.Conn, so this is a patch.
  • Inside transactions: the connections a Tx or Bulk function is given aren't pools, and their With and WithQueries still return a Conn.
  • Test: Test_PoolConnWith binds parameters and queries, runs a query, pings, and checks that closing it closes the pool.

So a type which keeps only the pool's connection with its queries can ping
and close the pool, with db.WithQueries(queries).(sqlite.PoolConn).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 19, 2026 09:10
@djthorpe djthorpe self-assigned this Nov 19, 2026
@github-actions

Copy link
Copy Markdown

Coverage for this change: 90.7%

@djthorpe
djthorpe merged commit dff99a8 into master Nov 19, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the changes preserving pool capabilities on bound connections.

No open issues 🎉

What changed in this PR

This PR preserves pool capabilities when binding parameters or queries to an ncruces connection. Derived handles can be asserted to sqlite.PoolConn to ping or close the shared pool, while method signatures continue to return sqlite.Conn.

Changes:

  • Add pool-specific With and WithQueries methods that retain the pool wrapper.
  • Add a test covering chained bindings, query execution, ping, and shared pool closure.
  • Document how to access pool lifecycle methods from a bound connection.
File Description
README.md Documents the sqlite.PoolConn assertion for bound pool connections.
ncruces/​pool.go Adds binding methods that return wrapped pool connections.
ncruces/​ncruces_test.go Tests bound pool handles and their shared lifecycle.

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants