Closed Jaymon closed 3 years ago
I left off one, basically just always mark those fields as modified and so any call to save()
would include those fields, I think this is the easiest to implement and I had this done in get_modified()
but depopulate()
doesn't use get_modified()
sigh
Anyway, I think the path forward is to just always mark those fields as modified and save them anytime save is called, I think the hassle of resaving those fields is pretty rare and so it's not worth implementing a complicated solution.
This issue is semi out-of-date with all the refactoring
similar to the problem with
JsonField
, let's say you have a custom container that stores in the db as a string, but when pulled out from the db it becomes aset()
or something similar, well, if you did something like:Then the modified fields wouldn't identify that the field has been changed, so there needs to be a way to account for this.
possible solutions:
pass a value into the
Field()
creation that basically says to always mark this as modified, something like:myset = Field(str, dirty=True)
when pulling values from the db take hashes of the values and compare those hashes with the the current values to determine what is modified, this would be a wholesale re-write of the current system and would be way slower to pull rows from the db, but would generic and wouldn't need the end user to be aware of anything
when pulling out of the db, if after calling
Field.isetter()
the value is no longer the same type as the what the field says (ie,myset
is stored in the db as a string but after callingmyset.issetter()
it is now aset
) then go ahead and automatically mark that field as modified, this would replace the current checks forObjectField
andJsonField
and the like since I think this system would be pretty generic, relatively fast (only one extraisinstance()
check) and wouldn't involve end user having to do anything.