MongoEngine / MongoEngine/mongoengine
fields not working properly
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
code segment
class SectorMapping(DynamicDocument):
date = DynamicField()
concept = DynamicField()
sub_concepts = DynamicField(default=[])
type = DynamicField()
end_date = DynamicField()
meta = {
'indexes': [
{
'fields': ['date', 'concept'],
'unique': True
},
{
'fields': ['date']
}
],
'db_alias': 'hunter',
'collection': 'sector_mapping'
}
sm = SectorMapping.objects.fields(_id=0, date=1, sub_concepts=0).first()
print(sm.to_mongo().to_dict())
output
{'date': datetime.datetime(2018, 9, 12, 0, 0), 'sub_concepts': []}
issue
I set the fields sub_concepts=0, but I got sub_concepts returned. Seems something wrong
version
mongoengine 0.15.3
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 provided SectorMapping example with MongoEngine 0.15.3 and inspect how DynamicDocument.fields() handles the projection. Confirm the expected result is that sub_concepts is omitted from sm.to_mongo().to_dict() when requested with sub_concepts=0.
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