Skip to content

Commit 11347f0

Browse files
committed
Fix Trunc functions RecursionError crash on non-MongoDB databases
1 parent e91193b commit 11347f0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

django_mongodb_backend/functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ def trunc(self, compiler, connection):
200200
return {"$dateTrunc": lhs_mql}
201201

202202

203+
_trunc_convert_value = TruncBase.convert_value
204+
205+
203206
def trunc_convert_value(self, value, expression, connection):
204207
if connection.vendor == "mongodb":
205208
# A custom TruncBase.convert_value() for MongoDB.
@@ -224,7 +227,7 @@ def trunc_convert_value(self, value, expression, connection):
224227
# Truncate for Trunc(..., output_field=TimeField)
225228
value = value.time()
226229
return value
227-
return self.convert_value(value, expression, connection)
230+
return _trunc_convert_value(self, value, expression, connection)
228231

229232

230233
def trunc_date(self, compiler, connection):

docs/source/releases/5.2.x.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ New features
1717
- Added :class:`~.fields.PolymorphicEmbeddedModelField` for storing a model
1818
instance that may be of more than one model class.
1919

20+
Bug fixes
21+
---------
22+
23+
- Fixed ``RecursionError`` when using ``Trunc`` database functions on non-MongoDB
24+
databases.
25+
2026
5.2.0 beta 1
2127
============
2228

0 commit comments

Comments
 (0)