Model.objects.none().values(...).anything() is broken
|Reported by:||Carl Meyer||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
There's a bug in the interaction of EmptyQuerySet and ValuesQuerySet; chaining .none() with .values() and then following that with any QuerySet method that causes a clone results in "AttributeError: 'ValuesQuerySet' object has no attribute 'field_names'".
(Obviously this chain is useless in the simple case, but the utility of .none() is for methods that need to return a QuerySet but in some cases should return one with no results; this can easily break in such cases if the caller of that method does further processing the returned queryset that includes .values()).