MongoEngine / MongoEngine/mongoengine

Issue filtering default boolean

Open
#1,709 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Model Migration
Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

I have the exact same issue as #1090 by @moneydance which was closed without an answer.

I have a Django project with a Post model and some documents already in db. Then added the field train = BooleanField(default=False). All of my post documents have now a train field with value False. But Post.objects(train=False) throws zero documents, and Post.objects(train=None) throws all documents, which is not correct.

If I change train values to True and then to False again, then Post.objects(train=False) throws all documents, which is correct (I did this from reading issue #1090), but I shouldn't have to do this in order to make the filtering work correctly.

Django 1.11.7
MongoDB 3.4.10
mongoengine 0.15.0
python 3.5.2

Any help will be appreciated.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the BooleanField and Post.objects(train=False/train=None) behavior described with the listed Django, MongoDB, mongoengine, and Python versions, then compare issue #1090. Done means existing documents are filtered correctly for False and None without rewriting their field values.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.