#8819: Regression: filter by extra(select = ..., order_by = ...) with distinct()
fails ("Unknown column")
--------------------------------------+-------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: SVN
Keywords: | Stage: Unreviewed
Has_patch: 0 |
--------------------------------------+-------------------------------------
Regression: adding an extra field to a QuerySet using .extra(select = ...)
with extra(order_by = ...) AND .distinct() throws an OperationalError.
This seems to be because the generated SQL lists the extra column twice:
once correctly (as the derived field), and once just by itself at the end
of the SELECT list.
Reduced test case below (using contrib.auth for simplified test case,
though this is reproducible with any model).
{{{
import setup_django
from django.contrib.auth.models import User
a = User.objects.all().extra( select = { 'test_new_field': '1'
}).distinct()
b = User.objects.all().extra( select = { 'test_new_field': '1' }, order_by
= ['-test_new_field'] )
c = User.objects.all().extra( select = { 'test_new_field': '1' }, order_by
= ['-test_new_field'] ).distinct()
print a[:1]
print b[:1]
print c[:1]
}}}
(In the code above, "setup_django" just sets the right settings file,
etc.)
Expected: a, b, and c both evaluate without error.
Actual: a and b are fine, c raises OperationalError: (1054, "Unknown
column 'test_new_field' in 'field list'")
I haven't tracked this down to a particular rev yet, but it's almost
definitely within the past week or so.
--
Ticket URL: <http://code.djangoproject.com/ticket/8819>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---