diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-25 03:17:06 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-08-25 03:17:06 +0000 |
| commit | d535edb9da92f7de0c2ae35456b5b751db8e4d46 (patch) | |
| tree | 297f01400e74c28796b7e4f727a1e4c412377607 /tests | |
| parent | 6d6fb392b4732fa4ff77e918c06ffcd92e753d9b (diff) | |
Fixed #8510 -- Allow both strings (mostly for the admin) and integers to be
used in "month" and "day" filters on date/datetime fields. Without this commit,
SQLite behaved inconsistently after [8494].
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8526 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/model_regress/models.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/regressiontests/model_regress/models.py b/tests/regressiontests/model_regress/models.py index 9e11b43d2b..d79bbca3be 100644 --- a/tests/regressiontests/model_regress/models.py +++ b/tests/regressiontests/model_regress/models.py @@ -57,18 +57,26 @@ u'' >>> len(a4.article_text) 5000 -# #659 regression test +# Regression test for #659 >>> import datetime >>> p = Party.objects.create(when = datetime.datetime(1999, 12, 31)) >>> p = Party.objects.create(when = datetime.datetime(1998, 12, 31)) >>> p = Party.objects.create(when = datetime.datetime(1999, 1, 1)) ->>> [p.when for p in Party.objects.filter(when__month = 2)] +>>> [p.when for p in Party.objects.filter(when__month=2)] [] ->>> [p.when for p in Party.objects.filter(when__month = 1)] +>>> [p.when for p in Party.objects.filter(when__month=1)] [datetime.date(1999, 1, 1)] ->>> [p.when for p in Party.objects.filter(when__month = 12)] +>>> [p.when for p in Party.objects.filter(when__month=12)] [datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)] ->>> [p.when for p in Party.objects.filter(when__year = 1998)] +>>> [p.when for p in Party.objects.filter(when__year=1998)] +[datetime.date(1998, 12, 31)] + +# Regression test for #8510 +>>> [p.when for p in Party.objects.filter(when__day='31')] +[datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)] +>>> [p.when for p in Party.objects.filter(when__month='12')] +[datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)] +>>> [p.when for p in Party.objects.filter(when__year='1998')] [datetime.date(1998, 12, 31)] # Check that get_next_by_FIELD and get_previous_by_FIELD don't crash when we |
