question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can mongo_world=True work with missing_accessor=True?

See original GitHub issue

AFAIU, in as_marshmallow_schema, one can pass

missing_accessor=True, mongo_world=True

But it is bound to fail, because schema_from_umongo_get_attribute expects obj to be an object, not a dict.

def schema_from_umongo_get_attribute(self, attr, obj, default):
    ret = MaSchema.get_attribute(self, attr, obj, default)
    if ret is None and ret is not default and attr in obj.schema.fields:
        raw_ret = obj._data.get(attr)
        return default if raw_ret is missing else raw_ret
    else:
        return ret

Shouldn’t this be prevented? Like, by setting missing_accessor to False when mongo_world is True?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
touilleMancommented, Nov 29, 2016

I’m also realizing that I might lack this feature when serializing data from Mongo world. It makes output a bit different depending on the path used (directly from DB or through OO world).

Mongo world is supposed to always return you the raw data, so there is no need to provide a custom get_attribute. Thus Mongo world and OO world should provide the same consistent behavior (i.e. missing is handled by marshmallow-pure schema)

Currently, schema_from_umongo_get_attribute is broken in Mongo world

As stated above: it is not broken, it is not needed 😄

Given your summarize, I think we agree missing_accessor is doing more harm than good so I pushed a new version removing it. Beside, this feature should work with Mongo world as well as OO world, so open an issue if it’s not the case 👍

0reactions
lafrechcommented, Nov 29, 2016

OK, I get it. Removing it is the right thing to do.

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Query for boolean field as "not true" (e.g. either false or non ...
This query can use an index on {deleted: 1} in the current 2.6.6 MongoDB release. Share.
Read more >
Write Concern — MongoDB Manual
If j: true , requests acknowledgment that the mongod instances, as specified in the w: <value>, have written to the on-disk journal. j:...
Read more >
The Real #1, Others can claim it. We prove it!
Whether you're on the shooting line or in a tree stand, you can be confident knowing that your equipment is truly the best...
Read more >
Cannot connect to mongodb while allowInsecureConnection ...
Unfortunately, the NodeJS function example does not work out of the box because of this error either, and I see no concrete solution...
Read more >
Features — Eve 2.0.4 documentation
In general you will find that most MongoDB queries “just work”. ... can be enabled or disabled both at global level (by setting...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found