Loading django/db/models/fields/__init__.py +2 −1 Original line number Diff line number Diff line Loading @@ -1682,7 +1682,8 @@ class DurationField(Field): return value if value is None: return None return value.total_seconds() * 1000000 # Discard any fractional microseconds due to floating point arithmetic. return int(round(value.total_seconds() * 1000000)) def get_db_converters(self, connection): converters = [] Loading docs/releases/1.8.12.txt +3 −0 Original line number Diff line number Diff line Loading @@ -12,3 +12,6 @@ Bugfixes * Made ``MultiPartParser`` ignore filenames that normalize to an empty string to fix crash in ``MemoryFileUploadHandler`` on specially crafted user input (:ticket:`26325`). * Fixed data loss on SQLite where ``DurationField`` values with fractional seconds could be saved as ``None`` (:ticket:`26324`). docs/releases/1.9.5.txt +3 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,6 @@ Bugfixes * Fixed a race condition in ``BaseCache.get_or_set()`` (:ticket:`26332`). It now returns the ``default`` value instead of ``False`` if there's an error when trying to add the value to the cache. * Fixed data loss on SQLite where ``DurationField`` values with fractional seconds could be saved as ``None`` (:ticket:`26324`). tests/model_fields/test_durationfield.py +6 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,12 @@ class TestSaveLoad(TestCase): loaded = NullDurationModel.objects.get() self.assertEqual(loaded.field, None) def test_fractional_seconds(self): value = datetime.timedelta(seconds=2.05) d = DurationModel.objects.create(field=value) d.refresh_from_db() self.assertEqual(d.field, value) class TestQuerying(TestCase): Loading Loading
django/db/models/fields/__init__.py +2 −1 Original line number Diff line number Diff line Loading @@ -1682,7 +1682,8 @@ class DurationField(Field): return value if value is None: return None return value.total_seconds() * 1000000 # Discard any fractional microseconds due to floating point arithmetic. return int(round(value.total_seconds() * 1000000)) def get_db_converters(self, connection): converters = [] Loading
docs/releases/1.8.12.txt +3 −0 Original line number Diff line number Diff line Loading @@ -12,3 +12,6 @@ Bugfixes * Made ``MultiPartParser`` ignore filenames that normalize to an empty string to fix crash in ``MemoryFileUploadHandler`` on specially crafted user input (:ticket:`26325`). * Fixed data loss on SQLite where ``DurationField`` values with fractional seconds could be saved as ``None`` (:ticket:`26324`).
docs/releases/1.9.5.txt +3 −0 Original line number Diff line number Diff line Loading @@ -16,3 +16,6 @@ Bugfixes * Fixed a race condition in ``BaseCache.get_or_set()`` (:ticket:`26332`). It now returns the ``default`` value instead of ``False`` if there's an error when trying to add the value to the cache. * Fixed data loss on SQLite where ``DurationField`` values with fractional seconds could be saved as ``None`` (:ticket:`26324`).
tests/model_fields/test_durationfield.py +6 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,12 @@ class TestSaveLoad(TestCase): loaded = NullDurationModel.objects.get() self.assertEqual(loaded.field, None) def test_fractional_seconds(self): value = datetime.timedelta(seconds=2.05) d = DurationModel.objects.create(field=value) d.refresh_from_db() self.assertEqual(d.field, value) class TestQuerying(TestCase): Loading