Closed fgmacedo closed 8 years ago
Hi, I've found that prefetch_relations evaluates all queries, not alowing cascading further filters.
prefetch_relations
So, the following query will retrive all notifications from DB:
Notification.objects.active().filter(nf_type='my_type')
I think that we should remove the implicit call to prefetch_relations from the NotificationQueryset, and add a new queryset method like prefetch, to be explicit called when the context needs it. With a note that prefetch is not lazy.
NotificationQueryset
prefetch
The above example can be fixed using:
pretetch_relations(Notification.objects.filter(nf_type='badge_awarded'))
Or if we implement pretetch as a isolated queryset method:
pretetch
Notification.objects.filter(nf_type='badge_awarded').prefetch()
What do you think?
prefetch as a queryset method looks more clean to me. Are you already working on it?
Ok. Not yet. But it's something that I will need, so expect it to the next few days.
Hi, I've found that
prefetch_relations
evaluates all queries, not alowing cascading further filters.So, the following query will retrive all notifications from DB:
I think that we should remove the implicit call to
prefetch_relations
from theNotificationQueryset
, and add a new queryset method likeprefetch
, to be explicit called when the context needs it. With a note thatprefetch
is not lazy.The above example can be fixed using:
Or if we implement
pretetch
as a isolated queryset method:What do you think?