Files
synapse/tests
Erik JohnstonandClaude Opus 4.8 969a473d58 Add a DBAPI2 adapter over the Rust Postgres shim
Synapse's LoggingTransaction drives a cursor through the DBAPI2 spelling
(fetchone/fetchmany/fetchall, iteration, rowcount/description as properties),
but the Rust shim cursor exposes fetch_one/fetch_all/fetch_next_batch and
rowcount()/description() as methods. Rather than reshape the Rust API, add thin
Python `Connection`/`Cursor` wrappers that present the DBAPI2 shape and delegate
to the shim:

  - `Cursor` maps fetchone/fetchmany/fetchall/__iter__ and rowcount/description
    onto the shim, and tracks exhaustion so fetching past the end keeps
    returning "no more rows" (the shim raises instead);
  - `Connection.cursor()` returns the adapter cursor, and the transaction-control
    and engine-facing methods (commit/rollback/close, set_autocommit, is_closed,
    in_transaction) delegate straight through.

An end-to-end test drives a real LoggingTransaction backed by the adapter and
RustPostgresEngine: `?` placeholders are converted to `$n`, a query runs, and
rows come back via fetchone/iteration/description.

Not handled yet: execute_batch / execute_values (psycopg2 extras that
LoggingTransaction calls directly for PostgresEngine) still need a routing
change to reach a shim-backed implementation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3G4M92AmwSSZCbmtMJU3d
2026-07-11 09:04:57 +00:00
..
2026-06-02 11:05:38 +01:00