DATABASES Signal 247
Stop fucking around with database commits and transactions
If your code calls commit() inside nested helpers beneath a transaction decorator, the atomicity guarantee is an illusion—partial writes can persist on failure. The author argues the only reliable fix is to confine all DB sessions, transactions, queries, and models strictly within a dedicated DB access layer and to enforce that boundary with AST-based linters or test suites that ban manual commits and DB model imports outside that layer.
Written by elseif from the cluster below · every claim links back to a sourceThe three things worth knowing
Manual commits buried in helper functions called within a transaction context manager break atomicity because no caller can see that a partial commit occurs.
Passing ORM-backed DB models outside the data layer creates silent writes when properties are mutated, and removing transaction wrappers causes uncommitted data to vanish.
The author recommends enforcing DB layer boundaries via AST analysis or flake8 plugins that ban manual commits, DB session access, transaction access, and DB model imports outside the DB access layer.
THE CLUSTER