summaryrefslogtreecommitdiff
path: root/tests/regressiontests/extra_regress
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-04-30 15:40:09 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-04-30 15:40:09 +0000
commit5e2d38465a661fc267676798d3aa4872e9da8265 (patch)
treef1ed2888c0d1a731b2c5a44ff449408b24d23b15 /tests/regressiontests/extra_regress
parent17958fa7a9a757c2b0abcdc3f931a010584234f1 (diff)
Fixed #10847 -- Modified handling of extra() to use a masking strategy, rather than last-minute trimming. Thanks to Tai Lee for the report, and Alex Gaynor for his work on the patch.
This enables querysets with an extra clause to be used in an __in filter; as a side effect, it also means that as_sql() now returns the correct result for any query with an extra clause. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10648 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/extra_regress')
-rw-r--r--tests/regressiontests/extra_regress/models.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/regressiontests/extra_regress/models.py b/tests/regressiontests/extra_regress/models.py
index fd34982c9a..5d22d6cc07 100644
--- a/tests/regressiontests/extra_regress/models.py
+++ b/tests/regressiontests/extra_regress/models.py
@@ -35,6 +35,9 @@ class TestObject(models.Model):
second = models.CharField(max_length=20)
third = models.CharField(max_length=20)
+ def __unicode__(self):
+ return u'TestObject: %s,%s,%s' % (self.first,self.second,self.third)
+
__test__ = {"API_TESTS": """
# Regression tests for #7314 and #7372
@@ -189,6 +192,19 @@ True
>>> TestObject.objects.extra(select=SortedDict((('foo','first'),('bar','second'),('whiz','third')))).values_list('whiz', 'first', 'bar', 'id')
[(u'third', u'first', u'second', 1)]
-"""}
+# Regression for #10847: the list of extra columns can always be accurately evaluated.
+# Using an inner query ensures that as_sql() is producing correct output
+# without requiring full evaluation and execution of the inner query.
+>>> TestObject.objects.extra(select={'extra': 1}).values('pk')
+[{'pk': 1}]
+>>> TestObject.objects.filter(pk__in=TestObject.objects.extra(select={'extra': 1}).values('pk'))
+[<TestObject: TestObject: first,second,third>]
+>>> TestObject.objects.values('pk').extra(select={'extra': 1})
+[{'pk': 1}]
+
+>>> TestObject.objects.filter(pk__in=TestObject.objects.values('pk').extra(select={'extra': 1}))
+[<TestObject: TestObject: first,second,third>]
+
+"""}