mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #32699 -- Fixed comparing to TruncTime() with 0 microseconds on MySQL.
This commit is contained in:
committed by
Mariusz Felisiak
parent
c240ceea7d
commit
c4ee3b208a
@@ -923,6 +923,22 @@ class DateFunctionTests(TestCase):
|
||||
self.create_model(None, None)
|
||||
self.assertIsNone(DTModel.objects.annotate(truncated=TruncTime('start_datetime')).first().truncated)
|
||||
|
||||
def test_trunc_time_no_microseconds(self):
|
||||
start_datetime = datetime(2015, 6, 15, 14, 30, 26)
|
||||
if settings.USE_TZ:
|
||||
start_datetime = timezone.make_aware(start_datetime, is_dst=False)
|
||||
self.create_model(start_datetime, None)
|
||||
self.assertIs(
|
||||
DTModel.objects.filter(start_datetime__time=start_datetime.time()).exists(),
|
||||
True,
|
||||
)
|
||||
self.assertIs(
|
||||
DTModel.objects.annotate(
|
||||
extracted=TruncTime('start_datetime'),
|
||||
).filter(extracted=start_datetime.time()).exists(),
|
||||
True,
|
||||
)
|
||||
|
||||
def test_trunc_day_func(self):
|
||||
start_datetime = datetime(2015, 6, 15, 14, 30, 50, 321)
|
||||
end_datetime = truncate_to(datetime(2016, 6, 15, 14, 10, 50, 123), 'day')
|
||||
|
||||
Reference in New Issue
Block a user