-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hello,
I notice that the library is not raising the UnsealedAttributeAccess errors if you try to access a prefetched table with a different query. Take this model for example
class Company(SealableModel):
users = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True)If I try to access the company from the User it raises the error as expected:
User.objects.all().seal().first().company_set.all()
UnsealedAttributeAccess: Attempt to fetch many-to-many field "company" on sealed <User instance>.Now, if I prefetch the company_set the error disappears as expected:
for u in User.objects.prefetch_related('company_set').all().seal():
for c in u.company_set.all():
print(c) # no errors and 2 queriesThe problem is that django-seal cannot detect if the user changes the queryset:
for u in User.objects.prefetch_related('company_set').all().seal():
for c in u.company_set.order_by('-pk'):
print(c) # no errors and 4 queriesMetadata
Metadata
Assignees
Labels
No labels