MongoEngine / MongoEngine/mongoengine
Empty values handling in BooleanField
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
Currently to_mongo calls to_python regardless of the value being empty. This is different to the django behaviour.
The problem, that this causes, is that, for example, BooleanField saves false to the database, instead of null or StringField saves empty string. Django does check value being empty for the first and the second case.
To my opinion this is really misleading when I save document with an explicitly unset BooleanField and it saves with false value.
I'll be happy to provide a PR with these changes, if it wasnt done on purpose.
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 locating the BooleanField and StringField implementations and reading their to_mongo and to_python methods. Compare their empty-value handling with the Django field behavior linked in the issue, then add or update coverage so unset BooleanField values remain null and empty StringField values remain empty; done means these values are not coerced during persistence.
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
- 45/100