Repository navigation
Add fetch_all with optional borrowed connection and Pydantic model overload - #47
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lation Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… cancel tests) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ams-less t-string overloads Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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
Moves OneSales'
fetch_allintopgdevkit.db(0.13.0).fetch_all(query, params=None, *, model=None, row_mapper=None, con=None, pool=None, cancel=None)con=is borrowed: never committed, closed or returned to a pool. Without it a connection comes frompool=or the pool registered viaset_default_pool()(single-database apps; passpool=for several).model=(Pydantic) overload,row_mapper=overload, defaultlist[dict]. t-string queries get params-less overloads (they carry their own values).queryis typedLiteralString | sqlglot Expression | psycopg.sql Composable | t-string. sqlglot is imported lazily.cancel: asyncio.Eventaborts the running query server-side (cancel_safe()->QueryCanceled). Cancelling the awaiting task also cancels it server-side (CancelledErrorpropagates), drained uninterruptibly so no orphaned task/query; if the cancel request itself fails the connection is closed.psycopg>=3.3(t-strings).Notes for reviewers
_renderrejectsexp.Commandand malformed placeholder names; the docs say to pass user values asexp.Placeholder+params. Abdt lintrule for non-literal args to sqlglot builders is a follow-up (the current lint trusts sqlglot-derived text).cancel=aborts whatever statement runs on the connection, so don't use it on aconshared by concurrent tasks (documented).bdt lintcoverage forfetch_all/fetch_one/fetch_scalaris in feat(lint): apply SQL rules to pgdevkit fetch_all/fetch_one/fetch_scalar devtools#79.requires_podman; I also ran them against a local Postgres (14 passed, stable over repeated runs).