#22817: Missing custom methods on EmptyQuerySet
-------------------------------+--------------------
     Reporter:  benjaoming     |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.6
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 #19151 was basically reintroduced in 1.6 -- recap of the release notes:

 > The django.db.models.query.EmptyQuerySet can’t be instantiated any more
 - it is only usable as a marker class for checking if none() has been
 called: isinstance(qs.none(), EmptyQuerySet)

 Thus, if we try the case of #19151 in 1.7:


 {{{
 >>> AnonymousUser().groups.value_list('name')
 Traceback (most recent call last):
   File "<input>", line 1, in <module>
 AttributeError: 'EmptyManager' object has no attribute 'value_list'

 }}}

 I also have this issue in django-wiki and I don't know how to solve it:
 https://github.com/benjaoming/django-wiki/issues/216 (sorry it doesn't
 contain many details yet)

 The problem with the above is that basically when we have a custom manager
 and we want to call a custom function, we have to always check that we do
 not have an instance of EmptyQuerySet. I mean, how else can we call a
 custom method on a custom QuerySet if it's always subject to be an
 instance of a non-custom EmptyQuerySet ? :)

 I'm seeing behaviour as broken and should be reverted, but please correct
 me if I'm wrong and there's a way around this.

 I've heard that 1.7 will have a QuerySet.as_manager utility method, but
 this doesn't fix heaps of broken managers that rely on their own instances
 of EmptyQuerySet and cannot simply stop instantiating them because they
 use none() to transparently implement the same call pattern for both empty
 and non-empty querysets.

 In addition, maintaining compatibility of managers across 1.5 - 1.7 seems
 very painful without custom EmptyQuerySet instances.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22817>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.5b73487981296c17481523c3c2b9e0ac%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to