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
This is inspired by one of your blog posts (which I enjoy reading btw, keep it up!).
Basically it would remove any .all() call that is not the last one (except if there is a .delete())
-Digger.objects.all().filter(height_cm__gt=200)+Digger.objects.filter(height_cm__gt=200)
Digger.objects.all().delete() # Unchanged, since the `.all()` is required in this specific case
This will require some heuristics to know if we are actually checking a queryset chain but It should be doable (First element of the call chain imported from models, .all() following an objects and before any django queryset known methods, ...).
I'll be quoting youself for the benefits which are not huge but still nice to have I think.
Useless calls to .all() aren’t a large problem, but they do mean more code to read and a slight performance cost for the extra queryset copies. I think that avoiding them also shows you understand ORM methods a little bit better.
The text was updated successfully, but these errors were encountered:
Description
This is inspired by one of your blog posts (which I enjoy reading btw, keep it up!).
Basically it would remove any
.all()
call that is not the last one (except if there is a.delete()
)This will require some heuristics to know if we are actually checking a queryset chain but It should be doable (First element of the call chain imported from
models
,.all()
following anobjects
and before any django queryset known methods, ...).I'll be quoting youself for the benefits which are not huge but still nice to have I think.
The text was updated successfully, but these errors were encountered: