Ticket #18969: 18969-1.patch

File 18969-1.patch, 2.2 KB (added by Tomáš Ehrlich, 12 years ago)

Tests added

  • django/db/backends/__init__.py

    diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
    index 02d2a16..df38818 100644
    a b class BaseDatabaseOperations(object):  
    863863
    864864        `value` is an int, containing the looked-up year.
    865865        """
     866        value = str(value).zfill(4)
    866867        first = '%s-01-01 00:00:00'
    867868        second = '%s-12-31 23:59:59.999999'
    868869        return [first % value, second % value]
  • django/db/backends/mysql/base.py

    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):  
    316316
    317317    def year_lookup_bounds(self, value):
    318318        # Again, no microseconds
     319        value = str(value).zfill(4)
    319320        first = '%s-01-01 00:00:00'
    320321        second = '%s-12-31 23:59:59.99'
    321322        return [first % value, second % value]
  • django/db/backends/sqlite3/base.py

    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):  
    198198        return six.text_type(value)
    199199
    200200    def year_lookup_bounds(self, value):
     201        value = str(value).zfill(4)
    201202        first = '%s-01-01'
    202203        second = '%s-12-31 23:59:59.999999'
    203204        return [first % value, second % value]
  • tests/regressiontests/model_regress/tests.py

    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):  
    101101            attrgetter("when")
    102102        )
    103103
     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
    104113    def test_date_filter_null(self):
    105114        # Date filtering was failing with NULL date values in SQLite
    106115        # (regression test for #3501, amongst other things).
Back to Top