On v0.19.1, this works:
from mongoengine import *
class User(Document):
name = StringField()
connect("mongoenginetest", host="mongomock://localhost")
User.objects(name="Eric").update(name="John")
On the newly released v0.20.0, this fails with
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/kurt/Dropbox/Python/CALEA/calea-processor/venv/lib/python3.8/site-packages/mongoengine/queryset/base.py", line 540, in update
with set_read_write_concern(
File "/usr/local/Cellar/[email protected]/3.8.1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/contextlib.py", line 113, in __enter__
return next(self.gen)
File "/Users/kurt/Dropbox/Python/CALEA/calea-processor/venv/lib/python3.8/site-packages/mongoengine/context_managers.py", line 270, in set_read_write_concern
combined_read_concerns = dict(collection.read_concern.document.items())
TypeError: 'Collection' object is not callable
It also fails when using an explicit $set modifier operator with v0.20.0.
User.objects(name="Eric").update(set__name="John")
Just tried this and the issue isn't there with a regular mongodb, it will need to be investigated but it seems to be related to mongomock somehow
@kurthaegeman mongomock does not support read_concern. I'll push a PR in a bit.
@kurthaegeman PR submitted. https://github.com/mongomock/mongomock/pull/628
Closing this as issue was in mongomock
@kurthaegeman The fix has been merged into mongomock.
Unit tests now work (with mongomock-3.19.1.dev17). Nice work!
@kurthaegeman it is possible to install mongomock-3.19.1.dev17 version with pipenv? I tried but without success.
@kurthaegeman Where did you find version 3.19.1.dev17? Last version is 3.19.0. The issue is not fixed.
@alexciornii I pip-installed it from the git branch.
@kurthaegeman Thank you. It works for me too. Just should have been installed from the develop branch.
Hi @alexciornii you can install as shown below
pip install git+https://github.com/mongomock/mongomock.git@develop
As of today, it installs mongomock-3.19.1.dev19 and all unit work.
Most helpful comment
@alexciornii I pip-installed it from the git branch.