mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

Fix BaseDocument._from_son() deepcopy failed with compiled regex

Open StoneMoe opened this issue 5 years ago • 1 comments

Fix for issue https://github.com/MongoEngine/mongoengine/issues/2429

StoneMoe avatar Dec 04 '20 16:12 StoneMoe

Hi, thanks for the reviewing, I added more tests and changed approach for this fix based on that.

but there are some question might need more discussion:

  1. deepcopy() won't copy class-level attributes added by __new__, which is instance._fields in this case. which resulting in the test you request to add won't pass in the first place, is this expected or another bug for mongoengine?
  2. deepcopy() works for _fields attribute of the instance returned by _from_son(), but not work for the objects returned from queryset

StoneMoe avatar Dec 07 '20 08:12 StoneMoe