mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Fix: DictField are always marked as changed

Open jaesivsm opened this issue 4 years ago • 2 comments

Only triggering _mark_as_changed on DictField if the value is actually changed.

Limit the number of field accumulated in _changed_fields.

jaesivsm avatar Dec 15 '21 17:12 jaesivsm

Change is valid but I'm curious, how did you noticed it @jaesivsm ?

bagerard avatar Dec 28 '21 13:12 bagerard

Well it's a bit complex to describe without going in the specifics but I'm gonna try x)

We have a model with a field that gets set some values that shouldn't trigger a _mark_as_changed (because it's the same value). That's the issue this patch fixes. We also have function connected through a signal that checks Document._delta (I know it's not a "public" API :/ sorry) to list the field that were changed right before the db write. Depending of the field that were changed it'll trigger various stuff. That last part was the visible symptom.

jaesivsm avatar Dec 28 '21 15:12 jaesivsm

Hello @bagerard, do you think it would be possible to integrate that in the next release ?

jaesivsm avatar Feb 23 '23 16:02 jaesivsm