summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-04-28 04:28:59 +0000
committerBrian Rosner <brosner@gmail.com>2008-04-28 04:28:59 +0000
commit738e6d986ba41ec5ef9ba5a600a333916f2e763d (patch)
tree7f6ab31d75a109d4267e22e30678f108bbbc1d71 /tests
parent678b9a6f5a0dfdf571e6dc66ade5521314047deb (diff)
newforms-admin: Merged from trunk up to [7491].
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7492 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/many_to_one/models.py17
-rw-r--r--tests/regressiontests/queries/models.py4
2 files changed, 19 insertions, 2 deletions
diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py
index 6616f8b55e..53ad4466bb 100644
--- a/tests/modeltests/many_to_one/models.py
+++ b/tests/modeltests/many_to_one/models.py
@@ -246,7 +246,7 @@ FieldError: Cannot resolve keyword 'reporter_id' into field. Choices are: headli
>>> Reporter.objects.filter(article__reporter__exact=r).distinct()
[<Reporter: John Smith>]
-# Check that implied __exact also works
+# Check that implied __exact also works.
>>> Reporter.objects.filter(article__reporter=r).distinct()
[<Reporter: John Smith>]
@@ -266,11 +266,24 @@ True
>>> Reporter.objects.order_by('first_name')
[<Reporter: John Smith>]
-# Deletes using a join in the query
+# You can delete using a JOIN in the query.
>>> Reporter.objects.filter(article__headline__startswith='This').delete()
>>> Reporter.objects.all()
[]
>>> Article.objects.all()
[]
+# Check that Article.objects.select_related().dates() works properly when
+# there are multiple Articles with the same date but different foreign-key
+# objects (Reporters).
+>>> r1 = Reporter.objects.create(first_name='Mike', last_name='Royko', email='royko@suntimes.com')
+>>> r2 = Reporter.objects.create(first_name='John', last_name='Kass', email='jkass@tribune.com')
+>>> a1 = Article.objects.create(headline='First', pub_date=datetime(1980, 4, 23), reporter=r1)
+>>> a2 = Article.objects.create(headline='Second', pub_date=datetime(1980, 4, 23), reporter=r2)
+>>> Article.objects.select_related().dates('pub_date', 'day')
+[datetime.datetime(1980, 4, 23, 0, 0)]
+>>> Article.objects.select_related().dates('pub_date', 'month')
+[datetime.datetime(1980, 4, 1, 0, 0)]
+>>> Article.objects.select_related().dates('pub_date', 'year')
+[datetime.datetime(1980, 1, 1, 0, 0)]
"""}
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 483aa7218c..5529bced8b 100644
--- a/tests/regressiontests/queries/models.py
+++ b/tests/regressiontests/queries/models.py
@@ -654,5 +654,9 @@ Bug #7045 -- extra tables used to crash SQL construction on the second use.
>>> s = qs.query.as_sql()
>>> s = qs.query.as_sql() # test passes if this doesn't raise an exception.
+Bug #7098 -- Make sure semi-deprecated ordering by related models syntax still
+works.
+>>> Item.objects.values('note__note').order_by('queries_note.note', 'id')
+[{'note__note': u'n2'}, {'note__note': u'n3'}, {'note__note': u'n3'}, {'note__note': u'n3'}]
"""}