MongoEngine / MongoEngine/mongoengine
Problem with exclude EmbeddedDocumentListField
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
Hey.
I have a problem with exclude EmbeddedDocumentListField from my queryset.
I have a following code:
from mongoengine import (
Document, StringField,
EmbeddedDocumentListField, EmbeddedDocument
)
class Bar(Document):
name = StringField(max_length=256)
class Foo(EmbeddedDocument):
name = StringField(max_length=256)
arr = EmbeddedDocumentListField(Bar)
foo = Foo(name="f1")
foo.save()
When I exclude EmbeddedDocumentListField, I get:
>>> f = Foo.objects.all().exclude('arr')[0]
>>> f.to_json()
'{"_id": {"$oid": "5c0ef4280d068742e9ddcec5"}, "name": "a", "arr": []}
but when I exclude normal field like name I get :
>>> f = Foo.objects.all().exclude('name')[0]
>>> f.to_json()
'{"_id": {"$oid": "5c0ef4280d068742e9ddcec5"}, "arr": []}'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the EmbeddedDocumentListField case with the provided Foo, Bar, and Foo.objects.all().exclude('arr') queryset, then compare it with excluding name and inspect the queryset-to-document loading path. Done means excluding arr prevents the field from appearing in the serialized document, as name exclusion does.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100