Closed jayvdb closed 11 months ago
I've been unhappy with ObjectState
for a while and had started taking a look at what removing it entirely would look like. I cleaned up that branch a bit today and put out a draft PR #151. Take a look and see what you think about the direction.
It does still preserve the ability to error on Many.save
if referencing an auto-primary-key which hasn't been generated yet. It doesn't do any detection on non-automatic primary keys, although in that case the order of saving the Many vs. the object being referred to doesn't matter.
Fixed in #151
There are two main problems with
state.saved
.true
.Also it requires adding a field to the structs being stored in the database - this isnt a problem so much as it adds a lot of complexity.
The
state.saved
flag was necessary before upsert support. It looks like it is still necessary for inserts into auto-pk tables (but maybe that can be worked around also?).It is also used by the "dont save Many relationships linking to objects not yet persisted in the database" implementation at https://github.com/Electron100/butane/pull/116 , which IMO is a very good feature that I would hate to lose.
This issue is sort of a brain dump, with more investigation needed to see what direction that butane should take wrt this field. Maybe it is only more detailed documentation that is needed.