diff --git a/django_mongodb_backend/functions.py b/django_mongodb_backend/functions.py index 492316709..a93a30d3c 100644 --- a/django_mongodb_backend/functions.py +++ b/django_mongodb_backend/functions.py @@ -200,6 +200,9 @@ def trunc(self, compiler, connection): return {"$dateTrunc": lhs_mql} +_trunc_convert_value = TruncBase.convert_value + + def trunc_convert_value(self, value, expression, connection): if connection.vendor == "mongodb": # A custom TruncBase.convert_value() for MongoDB. @@ -224,7 +227,7 @@ def trunc_convert_value(self, value, expression, connection): # Truncate for Trunc(..., output_field=TimeField) value = value.time() return value - return self.convert_value(value, expression, connection) + return _trunc_convert_value(self, value, expression, connection) def trunc_date(self, compiler, connection): diff --git a/docs/source/releases/5.1.x.rst b/docs/source/releases/5.1.x.rst index 67d988859..8799ceef0 100644 --- a/docs/source/releases/5.1.x.rst +++ b/docs/source/releases/5.1.x.rst @@ -9,6 +9,8 @@ Django MongoDB Backend 5.1.x - Fixed crash when loading models with a null value for ``ArrayField``\s where the ``base_field`` uses a database converter. +- Fixed ``RecursionError`` when using ``Trunc`` database functions on non-MongoDB + databases. 5.1.0 beta 3 ============ diff --git a/docs/source/releases/5.2.x.rst b/docs/source/releases/5.2.x.rst index 54438be83..f0f09ab95 100644 --- a/docs/source/releases/5.2.x.rst +++ b/docs/source/releases/5.2.x.rst @@ -17,6 +17,12 @@ New features - Added :class:`~.fields.PolymorphicEmbeddedModelField` for storing a model instance that may be of more than one model class. +Bug fixes +--------- + +- Fixed ``RecursionError`` when using ``Trunc`` database functions on non-MongoDB + databases. + 5.2.0 beta 1 ============