1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Refs #33517 -- Prevented __second lookup from returning fractional seconds on PostgreSQL.

This commit is contained in:
nabil-rady
2022-02-21 03:28:19 +02:00
committed by Mariusz Felisiak
parent 659d2421c7
commit b7f263551c
3 changed files with 31 additions and 0 deletions

View File

@@ -899,6 +899,22 @@ class DateFunctionTests(TestCase):
2,
)
def test_extract_second_func_no_fractional(self):
start_datetime = datetime(2015, 6, 15, 14, 30, 50, 321)
end_datetime = datetime(2016, 6, 15, 14, 30, 50, 783)
if settings.USE_TZ:
start_datetime = timezone.make_aware(start_datetime)
end_datetime = timezone.make_aware(end_datetime)
obj = self.create_model(start_datetime, end_datetime)
self.assertSequenceEqual(
DTModel.objects.filter(start_datetime__second=F("end_datetime__second")),
[obj],
)
self.assertSequenceEqual(
DTModel.objects.filter(start_time__second=F("end_time__second")),
[obj],
)
def test_trunc_func(self):
start_datetime = datetime(999, 6, 15, 14, 30, 50, 321)
end_datetime = datetime(2016, 6, 15, 14, 10, 50, 123)