Skip to content

Ambient connection + bind/rows chain terminals - #18

Merged
adsharma merged 1 commit into
mainfrom
chain-rows-bind
Oct 5, 2026
Merged

adsharma merged 1 commit into
mainfrom
chain-rows-bind

Conversation

@adsharma

@adsharma adsharma commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Let's call sites read as pure chains instead of threading sessions through execution:

  • fquery/env.py: ContextVar ambient DBAPI connection — use(conn) / current() / connection() scope manager. Thread- and async-safe; set once per request/test.
  • Query.bind(**kw): stores param() bindings on the chain (wrapping ops inherit them via base init; same mutate-and-return convention as as_dict).
  • Query.rows(extra=None): terminal that runs on the ambient connection. Explicit to_rows(conn, params) unchanged.
UserQuery([]).where('user.id == param("uid")').bind(uid=2).project([...]).rows()

Tests cover bind+rows over sqlite3, missing-connection error, and param quoting.

fquery/env.py: ContextVar ambient DBAPI connection with use()/current()/connection() scope. Query.bind(**kw) stores param bindings on the chain (inherited by wrapping ops). Query.rows(extra=None) runs on the ambient connection. to_rows(conn, params) stays as the explicit form.
@adsharma
adsharma merged commit a8cdb82 into main Oct 5, 2026
2 checks passed
@adsharma
adsharma deleted the chain-rows-bind branch October 5, 2026 05:47
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.

1 participant