Skip to content

Allow cursors in externally managed transactions - #1350

Draft
aryansk wants to merge 1 commit into
MagicStack:masterfrom
aryansk:fix/1311-external-cursor-transaction
Draft

Allow cursors in externally managed transactions#1350
aryansk wants to merge 1 commit into
MagicStack:masterfrom
aryansk:fix/1311-external-cursor-transaction

Conversation

@aryansk

@aryansk aryansk commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Allow server-side cursors when the PostgreSQL connection is already inside a transaction started outside asyncpg's Transaction helper.

Changes

  • use the protocol-backed Connection.is_in_transaction() state instead of checking only _top_xact
  • preserve the existing error outside any transaction
  • add regression coverage for a transaction started with explicit BEGIN

Test plan

python -m unittest tests.test_cursor.TestCursor.test_cursor_external_transaction

Fixes #1311

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.

Cursor cannot be used with externally-managed transaction

1 participant