summaryrefslogtreecommitdiff
path: root/tests/db_functions
diff options
context:
space:
mode:
authorAlex Hill <alex@hill.net.au>2021-04-30 22:38:42 +0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-05-07 08:13:40 +0200
commitc4ee3b208a2c95a5102b5e4fa789b10f8ee29b84 (patch)
tree57912901bfd10164e5c435dac3e262e2b7b01c68 /tests/db_functions
parentc240ceea7d88c6a8058dcacb37356c93e0a3618f (diff)
downloaddjango-c4ee3b208a2c95a5102b5e4fa789b10f8ee29b84.tar.gz
Fixed #32699 -- Fixed comparing to TruncTime() with 0 microseconds on MySQL.
Diffstat (limited to 'tests/db_functions')
-rw-r--r--tests/db_functions/datetime/test_extract_trunc.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/db_functions/datetime/test_extract_trunc.py b/tests/db_functions/datetime/test_extract_trunc.py
index 63040f5198..75b8a4f0f9 100644
--- a/tests/db_functions/datetime/test_extract_trunc.py
+++ b/tests/db_functions/datetime/test_extract_trunc.py
@@ -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')