ELSEIF
Your brief EB
183 stories from 71 feeds 32 clusters Refreshed 9 minutes ago next pull 13:20

DATABASES Signal 247

Stop fucking around with database commits and transactions

WHY IT MATTERS

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 source

The three things worth knowing

01

Manual commits buried in helper functions called within a transaction context manager break atomicity because no caller can see that a partial commit occurs.

02

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.

03

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

Same story, 1 feed.

ORDERED BY FIRST SEEN
Hacker News Stop fucking around with database commits and transactions Open ↗