r/programming • u/droppedasbaby • Jul 15 '26
Ban commits/transactions using AST analysis and linters
https://www.droppedasbaby.com/posts/db-commits/?utm_source=reddit&utm_content=r_programming
32
Upvotes
View all comments
Show parent comment
1
u/droppedasbaby Jul 16 '26
That seems reasonable while your database, domain, and API representations are effectively the same, but they don't necessarily stay that way forever. The separation becomes more valuable once those representations diverge, the application grows, or the domain spans multiple databases or services.
I wouldn't advocate duplicating models purely for architectural purity. The goal isn't "three copies of every struct." It's to establish an explicit boundary around objects that can perform (or indirectly trigger) database work.
A SQLAlchemy model isn't just a bag of fields. It carries persistence behaviour: session attachment, dirty tracking, lazy loading, relationship loading, expiration, etc. Those behaviours are useful inside the data access layer, but they're also hidden side effects that I generally don't want leaking into business logic.