diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 02d2a16..df38818 100644
a
|
b
|
class BaseDatabaseOperations(object):
|
863 | 863 | |
864 | 864 | `value` is an int, containing the looked-up year. |
865 | 865 | """ |
| 866 | value = str(value).zfill(4) |
866 | 867 | first = '%s-01-01 00:00:00' |
867 | 868 | second = '%s-12-31 23:59:59.999999' |
868 | 869 | return [first % value, second % value] |
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 4043014..8fb560a 100644
a
|
b
|
class DatabaseOperations(BaseDatabaseOperations):
|
316 | 316 | |
317 | 317 | def year_lookup_bounds(self, value): |
318 | 318 | # Again, no microseconds |
| 319 | value = str(value).zfill(4) |
319 | 320 | first = '%s-01-01 00:00:00' |
320 | 321 | second = '%s-12-31 23:59:59.99' |
321 | 322 | return [first % value, second % value] |
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 0f0b6b7..4f28898 100644
a
|
b
|
class DatabaseOperations(BaseDatabaseOperations):
|
198 | 198 | return six.text_type(value) |
199 | 199 | |
200 | 200 | def year_lookup_bounds(self, value): |
| 201 | value = str(value).zfill(4) |
201 | 202 | first = '%s-01-01' |
202 | 203 | second = '%s-12-31 23:59:59.999999' |
203 | 204 | return [first % value, second % value] |
diff --git a/tests/regressiontests/model_regress/tests.py b/tests/regressiontests/model_regress/tests.py
index 6a45a83..70d9fc0 100644
a
|
b
|
class ModelTests(TestCase):
|
101 | 101 | attrgetter("when") |
102 | 102 | ) |
103 | 103 | |
| 104 | # Regression test for #18969 |
| 105 | Party.objects.create(when=datetime.datetime(1, 1, 1)) |
| 106 | self.assertQuerysetEqual( |
| 107 | Party.objects.filter(when__year=1), [ |
| 108 | datetime.date(1, 1, 1), |
| 109 | ], |
| 110 | attrgetter("when") |
| 111 | ) |
| 112 | |
104 | 113 | def test_date_filter_null(self): |
105 | 114 | # Date filtering was failing with NULL date values in SQLite |
106 | 115 | # (regression test for #3501, amongst other things). |