Skip to content

Commit 33bdcc2

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

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-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.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
============

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy