Author: mtredinnick
Date: 2007-10-13 22:46:44 -0500 (Sat, 13 Oct 2007)
New Revision: 6504
Modified:
django/branches/queryset-refactor/django/db/models/sql/query.py
django/branches/queryset-refactor/tests/regressiontests/queries/models.py
Log:
queryset-refactor: Fixed handling of extra(tables=...). In passing, this solves
a duplicate table / bad SQL problem. Refs #2496.
Modified: django/branches/queryset-refactor/django/db/models/sql/query.py
===================================================================
--- django/branches/queryset-refactor/django/db/models/sql/query.py
2007-10-14 03:46:20 UTC (rev 6503)
+++ django/branches/queryset-refactor/django/db/models/sql/query.py
2007-10-14 03:46:44 UTC (rev 6504)
@@ -371,7 +371,11 @@
qn(lhs_col), qn(alias), qn(col)))
else:
result.append('%s%s' % (qn(name), alias_str))
- result.extend(self.extra_tables)
+ extra_tables = []
+ for t in self.extra_tables:
+ alias, created = self.table_alias(t)
+ if created:
+ result.append(', %s' % alias)
return result, []
def get_grouping(self):
Modified:
django/branches/queryset-refactor/tests/regressiontests/queries/models.py
===================================================================
--- django/branches/queryset-refactor/tests/regressiontests/queries/models.py
2007-10-14 03:46:20 UTC (rev 6503)
+++ django/branches/queryset-refactor/tests/regressiontests/queries/models.py
2007-10-14 03:46:44 UTC (rev 6504)
@@ -202,5 +202,9 @@
[<Author: a3>]
>>> Tag.objects.filter(item__isnull=True)
[<Tag: t5>]
+
+Bug #2496
+>>>
Item.objects.extra(tables=['queries_author']).select_related().order_by('name')[:1]
+[<Item: four>]
"""}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---