summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-11-16 08:48:24 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-11-16 08:48:24 +0000
commit9d0bacebd2d0fc2b3581dac9acdc631338387921 (patch)
tree3b6c2f16bb3e7aea0e42b5d14bc3c945e64717a6 /tests
parent98ec741a03221e2b2a4c465e04ddede0795185af (diff)
Fixed #3501 -- Fixed date filtering in querysets for nullable date fields. Only
affects SQLite. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9466 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/model_regress/models.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/regressiontests/model_regress/models.py b/tests/regressiontests/model_regress/models.py
index 2f2c2facd5..19d38b216c 100644
--- a/tests/regressiontests/model_regress/models.py
+++ b/tests/regressiontests/model_regress/models.py
@@ -27,7 +27,7 @@ class Movie(models.Model):
name = models.CharField(max_length=60)
class Party(models.Model):
- when = models.DateField()
+ when = models.DateField(null=True)
class Event(models.Model):
when = models.DateTimeField()
@@ -93,6 +93,16 @@ u''
>>> [p.when for p in Party.objects.filter(when__year='1998')]
[datetime.date(1998, 12, 31)]
+# Date filtering was failing with NULL date values in SQLite (regression test
+# for #3501, amongst other things).
+>>> _ = Party.objects.create()
+>>> p = Party.objects.filter(when__month=1)[0]
+>>> p.when
+datetime.date(1999, 1, 1)
+>>> l = Party.objects.filter(pk=p.pk).dates("when", "month")
+>>> l[0].month == 1
+True
+
# Check that get_next_by_FIELD and get_previous_by_FIELD don't crash when we
# have usecs values stored on the database
#