-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Errors are not raised on prefetched table with different queries #49
Comments
This is currently done by design. As soon as a queryset clone is created due a queryset operation the queryset is unsealed django-seal/seal/descriptors.py Lines 31 to 40 in 75c1697
I guess we could emit a different kind of warning when this happens (e.g. |
Hi @charettes I am not sure if it's related, but I was able to "bypass" the seal even without the prefetch: This one raises the error:
This one doesn't
Personally I would prefer that those cases were at least logged by the library. My use case is that I have a DRF endpoint that displays a nested structure with 3 models deep. I want to make sure that the sealed queryset defined at the view is enough for the whole endpoint, but right now if someone changes any reverse lookup it would invalidate the prefetch related silently. |
@charettes Yes! I think so! |
I got a question. When will the warning be emitted exactly? Is it issued when the pretech call is executed or when an unwanted extra query is executed? |
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 exampleIf I try to access the company from the User it raises the error as expected:
Now, if I prefetch the
company_set
the error disappears as expected:The problem is that django-seal cannot detect if the user changes the queryset:
The text was updated successfully, but these errors were encountered: