MongoEngine / MongoEngine/mongoengine
Potential regression in handling of the _cls field
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
Hi,
Consider the following example:
from mongoengine import *
connect('test', host='mongodb://localhost/test')
class Page(Document):
title = StringField()
meta = {'allow_inheritance': True}
class DatedPage(Page):
date = DateTimeField()
page = DatedPage()
page.save()
assert '_cls' not in (key for key in page)
With mongoengine 0.8.x the _cls key was not returned during iteration, which I think is the correct behaviour.
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 with the Python reproduction in the issue and inspect MongoEngine's document iteration and handling of the internal _cls field for inherited documents. Confirm the behavior against MongoDB, then add regression coverage showing that iterating a saved DatedPage does not expose _cls; done when the assertion passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100