mongoengine icon indicating copy to clipboard operation
mongoengine copied to clipboard

LazyReferenceField requires check for None before using fetch() or pk

Open gmclark opened this issue 3 years ago • 0 comments

Hello, I'm relatively new to MongoEngine so I apologize in advance if this is a bad idea for some reason. That said, it seems like using LazyReferenceField would be much nicer if one didn't have to to check whether the field has a value before calling fetch() or accessing pk. Why not just have build_lazyref() allow for None to be passed on as the value of the LazyReference, and then have LazyReference.fetch() return None if self.id = None?

I'm willing to try setting up a dev environment and creating a PR for this if people think it's a good suggestion. Thanks for reading!

gmclark avatar May 02 '22 20:05 gmclark