You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to implement my own Reference class with a custom fetch method and i've noticed that ReferenceField has a reference_cls argument. I have tried to use it with my own Reference inheriting from MotorAsyncIOReference, but it didn't work well. By looking at the ReferenceField sources i noticed that the field itself actually uses a new reference_cls. I've also looked at umongo.frameworks.motor_asyncio and found out that MotorAsyncIOReference is hardcoded in MotorAsyncIOBuilder._patch_field. Is there a reason for that?
Or perhaps we can get rid of umongo.data_objects.Reference as a default value for reference_cls in ReferenceField constructor and only set default framework reference if user did not set his own.
I didn't take the time to investigate much but from what you're writing here, we could do what you propose.
Use None as default and override in framework if None. I wouldn't even bother adding the compatibility check. Modifying this is an advanced feature and the user should know what he's doing.
I would like to implement my own Reference class with a custom fetch method and i've noticed that
ReferenceField
has areference_cls
argument. I have tried to use it with my own Reference inheriting fromMotorAsyncIOReference
, but it didn't work well. By looking at theReferenceField
sources i noticed that the field itself actually uses a newreference_cls
. I've also looked atumongo.frameworks.motor_asyncio
and found out thatMotorAsyncIOReference
is hardcoded inMotorAsyncIOBuilder._patch_field
. Is there a reason for that?umongo/umongo/frameworks/motor_asyncio.py
Lines 431 to 433 in 7d199db
I am not familiar with the code and the library development in general but could this be fixed by doing something like this?
Or perhaps we can get rid of
umongo.data_objects.Reference
as a default value forreference_cls
inReferenceField
constructor and only set default framework reference if user did not set his own.I came up with this solution and i am pretty sure there is more elegant way to do it. Obviously, this should be done for every framework
The text was updated successfully, but these errors were encountered: