summaryrefslogtreecommitdiff
path: root/tests/regressiontests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-01-16 10:59:43 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2009-01-16 10:59:43 +0000
commitd579e716fef9f06f04861815cf949630d8633271 (patch)
tree103cbb5904b5a951be026ecbe2f7ff48a7056004 /tests/regressiontests
parent14b3f03015081a679a6b5efaf5ea925344ce14c0 (diff)
Fixed #9997 -- Fixed use of ValuesQuerySets as rvalues in filters.
Previous behaviour was pretty stupid. Let's never speak of it again. New behaviour both works and is documented. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9759 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests')
-rw-r--r--tests/regressiontests/queries/models.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index b32a0c5a63..e8cf645633 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -1022,6 +1022,22 @@ nothing).
>>> print Annotation.objects.filter(notes__in=Note.objects.filter(note="xyzzy")).query
SELECT ...
+Bug #9997 -- If a ValuesList or Values queryset is passed as an inner query, we
+make sure it's only requesting a single value and use that as the thing to
+select.
+>>> Tag.objects.filter(name__in=Tag.objects.filter(parent=t1).values('name'))
+[<Tag: t2>, <Tag: t3>]
+
+# Multi-valued values() and values_list() querysets should raise errors.
+>>> Tag.objects.filter(name__in=Tag.objects.filter(parent=t1).values('name', 'id'))
+Traceback (most recent call last):
+...
+TypeError: Cannot use a multi-field ValuesQuerySet as a filter value.
+>>> Tag.objects.filter(name__in=Tag.objects.filter(parent=t1).values_list('name', 'id'))
+Traceback (most recent call last):
+...
+TypeError: Cannot use a multi-field ValuesListQuerySet as a filter value.
+
Bug #9985 -- qs.values_list(...).values(...) combinations should work.
>>> Note.objects.values_list("note", flat=True).values("id").order_by("id")
[{'id': 1}, {'id': 2}, {'id': 3}]