#25754: queryset.distinct('field') doesn't raise "DISTINCT ON not supported" 
when
it should
-------------------------------------+-------------------------------------
     Reporter:  yoyoma               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  distinct             |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by yoyoma):

 bmispelon,

 Correct. Running {{{isinstance(queryset)}}} should NOT evaluate the
 queryset. However, placing {{{queryset}}} directly into the shell should
 (e.g., the example that you said you tried - what version of
 Django/Python/ipython are you running?).

 The following was actually copy/pasted from my shell, this very moment:

 {{{
 In [4]: Answer.objects.distinct('text')
 Out[4]:
 In [5]: Answer.objects.distinct('query')
 Out[5]:
 In [6]: type(Answer.objects.distinct('query'))
 Out[6]: django.db.models.query.QuerySet
 }}}

 Does that even look normal? Of course not. Unless an expression is
 {{{None}}}, its shell representation is usually visible.

 My model looks exactly like this:

 {{{
 class Answer(models.Model):
     created_at = models.DateTimeField(
         _('created at'),
         default=timezone.now,
         editable=False
     )
     updated_at = models.DateTimeField(_('updated at'), auto_now=True)
     query = models.ForeignKey('queries.Query', verbose_name=_('query'))
     text = models.TextField(_('text'))
 }}}

 There isn't a custom manager.

--
Ticket URL: <https://code.djangoproject.com/ticket/25754#comment:5>
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/064.ac65fa4e95cba8755721390623198648%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to