Skip to content

fix(#648): restore psycopg autocommit after transactions#652

Merged
cofin merged 1 commit into
mainfrom
fix/648-psycopg-autocommit
Jul 22, 2026
Merged

fix(#648): restore psycopg autocommit after transactions#652
cofin merged 1 commit into
mainfrom
fix/648-psycopg-autocommit

Conversation

@cofin

@cofin cofin commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

  • track SQLSpec transaction ownership separately from libpq transaction status
  • restore the connection's original autocommit mode after successful commit or rollback
  • preserve transaction state when native completion fails and report autocommit restoration failures separately
  • keep inherited Cockroach retry and statement-stack paths from taking ownership of implicit psycopg transactions

Fixes #648.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.07%. Comparing base (ed4ed5f) to head (cd8742e).

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #652    +/-   ##
========================================
  Coverage   77.06%   77.07%            
========================================
  Files         475      475            
  Lines       67212    67252    +40     
  Branches    10075     9182   -893     
========================================
+ Hits        51800    51832    +32     
- Misses      12017    12024     +7     
- Partials     3395     3396     +1     
Flag Coverage Δ
integration 60.68% <86.95%> (+0.01%) ⬆️
py3.10 75.36% <100.00%> (+0.01%) ⬆️
py3.11 75.37% <100.00%> (+0.01%) ⬆️
py3.12 75.37% <100.00%> (+0.01%) ⬆️
py3.13 75.37% <100.00%> (+0.01%) ⬆️
py3.14 76.25% <100.00%> (+<0.01%) ⬆️
unit 64.44% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sqlspec/adapters/psycopg/driver.py 83.67% <100.00%> (+1.20%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cofin
cofin marked this pull request as ready for review July 22, 2026 13:53
@cofin
cofin merged commit cfc05e8 into main Jul 22, 2026
24 checks passed
@cofin
cofin deleted the fix/648-psycopg-autocommit branch July 22, 2026 13:53
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.

psycopg: begin() permanently flips pooled autocommit connections to autocommit=False

2 participants