Only set no_cursor_timeout when requested

Previously this was always set for all requests. The parameter is only
documented as supported for certain queries, so this was probably wrong.

Mongo version 4.2 fails update queries that have this parameter set making
mongoengine unusable there. Fixes #2148.
This commit is contained in:
Arto Jantunen 2019-09-03 14:36:06 +03:00
parent 693195f70b
commit 47f8a126ca

View File

@ -1576,7 +1576,9 @@ class BaseQuerySet(object):
if self._snapshot: if self._snapshot:
msg = "The snapshot option is not anymore available with PyMongo 3+" msg = "The snapshot option is not anymore available with PyMongo 3+"
warnings.warn(msg, DeprecationWarning) warnings.warn(msg, DeprecationWarning)
cursor_args = {"no_cursor_timeout": not self._timeout} cursor_args = {}
if not self._timeout:
cursor_args["no_cursor_timeout"] = True
if self._loaded_fields: if self._loaded_fields:
cursor_args[fields_name] = self._loaded_fields.as_dict() cursor_args[fields_name] = self._loaded_fields.as_dict()