Skip to content

Commit a81779c

Browse files
committed
Fix Trunc functions RecursionError crash on non-MongoDB databases
1 parent 4a4f89e commit a81779c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

django_mongodb_backend/functions.py

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

201201

202+
_trunc_convert_value = TruncBase.convert_value
203+
204+
202205
def trunc_convert_value(self, value, expression, connection):
203206
if connection.vendor == "mongodb":
204207
# A custom TruncBase.convert_value() for MongoDB.
@@ -223,7 +226,7 @@ def trunc_convert_value(self, value, expression, connection):
223226
# Truncate for Trunc(..., output_field=TimeField)
224227
value = value.time()
225228
return value
226-
return self.convert_value(value, expression, connection)
229+
return _trunc_convert_value(self, value, expression, connection)
227230

228231

229232
def trunc_date(self, compiler, connection):

docs/source/releases/5.1.x.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Django MongoDB Backend 5.1.x
99

1010
- Fixed crash when loading models with a null value for ``ArrayField``\s where
1111
the ``base_field`` uses a database converter.
12+
- Fixed ``RecursionError`` when using ``Trunc`` database functions on non-MongoDB
13+
databases.
1214

1315
5.1.0 beta 3
1416
============

0 commit comments

Comments
 (0)