MongoEngine / MongoEngine/mongoengine

__only_fields is always none, even if input "values["__only_fields"]" has a value when initializing BaseDocument

Open
#2,333 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I realized something was up when I assigned a value to values["__only_fields"], and nothing was happening. It was only realized when I stepped through the debugger that I saw what was happening

I am talking about this part:

https://github.com/MongoEngine/mongoengine/blob/master/mongoengine/base/document.py#L83

When I assign something to values["__only_fields"] I am still getting none for __only_fields. This is what I see in the console debugger:

code I modified to show what I am talking about:

__auto_convert = values.pop("__auto_convert", True)

g = values.pop("__only_fields", values)

__only_fields = set(g)

when I explore things in the console:
Screen Shot 2020-05-22 at 11 43 06 AM

What's happening? When I do name mangling in the python interpreter, the output of set on the list is not None. I think that if you were intending this to be None, then just assign it none. Otherwise it blows my mind that the output of a set is None.

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

Inspect mongoengine/base/document.py around line 83 and reproduce initialization with values["__only_fields"] set. Compare the debugger result with the expected handling of __only_fields, then define the intended behavior and verify that the issue is resolved with a focused regression test.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.