flask-rest-jsonapi
flask-rest-jsonapi copied to clipboard
Model relationship with lazy='dynamic' doesn't return in ResourceRelationship
trafficstars
I noticied when in a model you configured a field as lazy='dynamic', the ResourceRelationship faild because the relational object is a query, and not a InstrumentedList.
Possible Fix:
data_layers/alchemy.py:246
Add:
if hasattr(related_objects, 'all'): related_objects = InstrumentedList(related_objects.all())
We know the dynamic lazy relationships are only for many to many or ont to many. So we know if the related_objects var has the 'all' attribute, we must to call .all() and return the InstrumentedList to continue with the flow.
any other idea, please tell me!!
Sorry for my Englsih :-(