We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In MongoEngineDoc, it says that
with no_dereference(Post) as Post: post = Post.objects.first()
works the similar way as
post = Post.objects.no_dereference().first()
Both of them can turn off dereference. However the first one doesn't seems work and the result still dereference data. Is that a bug?
Version mongoengine (0.10.6)
Platform Ubuntu 14.04
Test Code
#!/usr/bin/env python #coding: utf-8 from mongoengine import * from mongoengine.context_managers import no_dereference connect('issueTest', host='localhost', port=27017) class User(Document): email = StringField(required=True) class Post(Document): title = StringField(max_length=120, required=True) author = ReferenceField(User) tags = ListField(StringField(max_length=30)) user = User(email="[email protected]") user.save() post = Post(title="testPost", tags=["test", "test2"], author=user) post.save() with no_dereference(Post) as Post: post = Post.objects().first() print post.title, post.tags, post.author post = Post.objects().first() print post.title, post.tags, post.author post = Post.objects().no_dereference().first() print post.title, post.tags, post.author
Output
testPost [u'test', u'test2'] User object testPost [u'test', u'test2'] User object testPost [u'test', u'test2'] DBRef('user', ObjectId('56d68dad8649a53948aa5b90'))
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
In MongoEngineDoc, it says that
works the similar way as
Both of them can turn off dereference. However the first one doesn't seems work and the result still dereference data. Is that a bug?
Version
mongoengine (0.10.6)
Platform
Ubuntu 14.04
Test Code
Output
The text was updated successfully, but these errors were encountered: