Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling .only() on a field that has not been set does not go to default value #2398

Open
Gentatsu opened this issue Oct 20, 2020 · 0 comments
Open

Comments

@Gentatsu
Copy link

@Gentatsu Gentatsu commented Oct 20, 2020

I've had this issue a few times now, where I'm calling .only() for efficiency, and then when using the value, I don't get the default, I get None returned.

Other fields not specified in the .only() function do get set to their default value, however.

Reproduce:


class Example(Document):
    meta = {"collection": "example"}

    str1 = StringField(default="hi")
    str2 = StringField(default="hi2")

Example().save()
a = Example.objects.only("str1").first() # a.str1 == None, a.str2 == "hi2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.