# transaction has been commented out
# with transaction():
db_models = DBAccess.fetch_records(ids)
db_models[0].yo_mama_fat = True
# request ends, data poofs into the ether
tbh if this doesn't fail either immediately (no open transaction == error on modification attempt) or at GC time (if there's some kind of deferred logic), then I'd say this is an extremely bad framework and it does hold a major part of the blame. "You can mutate database-connected objects and sometimes they save back to the DB, sometimes they do not" is not reasonable behavior.
(obviously these frameworks exist. quite a few of them. quantity does not in any way imply sanity.)
> 2. DO NOT pass DB models in and out of the DB layer.
Yea, the more I've used "thin" ORMs that give you plain objects, the more I've grown convinced they're the best choice basically all the time. Trying to be magical is cute, but it's guaranteed to be made of spicy unobtanium, and at some point it'll blow up in your face in an extremely convoluted way due to a simple cause that you'll notice is absolutely everywhere and you're just stuck being paranoid forever. There's no need to live like that.
At a glance that looks like exactly what I like, yeah. Object mappers are 100% worth the effort and are often faster than hand translating the objects (because they'll cache and do things that are annoying or error-prone to do by hand) (code generation is nice too, Android has a couple that do that), and plain inline SQL strings with vars are FAR easier to learn and reason about and can take advantage of any database and any feature, including custom ones.
(obviously these frameworks exist. quite a few of them. quantity does not in any way imply sanity.)
> 2. DO NOT pass DB models in and out of the DB layer.
Yea, the more I've used "thin" ORMs that give you plain objects, the more I've grown convinced they're the best choice basically all the time. Trying to be magical is cute, but it's guaranteed to be made of spicy unobtanium, and at some point it'll blow up in your face in an extremely convoluted way due to a simple cause that you'll notice is absolutely everywhere and you're just stuck being paranoid forever. There's no need to live like that.