Merge pull request #847 from fhahn/ticket_18176
Fixed #18176 -- Added test for year lookups with year < 1000
This commit is contained in:
commit
86b96038f2
|
@ -57,6 +57,7 @@ class ModelTests(TestCase):
|
||||||
Party.objects.create(when=datetime.datetime(1999, 12, 31))
|
Party.objects.create(when=datetime.datetime(1999, 12, 31))
|
||||||
Party.objects.create(when=datetime.datetime(1998, 12, 31))
|
Party.objects.create(when=datetime.datetime(1998, 12, 31))
|
||||||
Party.objects.create(when=datetime.datetime(1999, 1, 1))
|
Party.objects.create(when=datetime.datetime(1999, 1, 1))
|
||||||
|
Party.objects.create(when=datetime.datetime(1, 3, 3))
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
Party.objects.filter(when__month=2), []
|
Party.objects.filter(when__month=2), []
|
||||||
)
|
)
|
||||||
|
@ -104,6 +105,20 @@ class ModelTests(TestCase):
|
||||||
attrgetter("when")
|
attrgetter("when")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Regression test for #18969
|
||||||
|
self.assertQuerysetEqual(
|
||||||
|
Party.objects.filter(when__year=1), [
|
||||||
|
datetime.date(1, 3, 3),
|
||||||
|
],
|
||||||
|
attrgetter("when")
|
||||||
|
)
|
||||||
|
self.assertQuerysetEqual(
|
||||||
|
Party.objects.filter(when__year='1'), [
|
||||||
|
datetime.date(1, 3, 3),
|
||||||
|
],
|
||||||
|
attrgetter("when")
|
||||||
|
)
|
||||||
|
|
||||||
def test_date_filter_null(self):
|
def test_date_filter_null(self):
|
||||||
# Date filtering was failing with NULL date values in SQLite
|
# Date filtering was failing with NULL date values in SQLite
|
||||||
# (regression test for #3501, amongst other things).
|
# (regression test for #3501, amongst other things).
|
||||||
|
|
Loading…
Reference in New Issue