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.

Nested excludes get overwritten

See original GitHub issue

It seems whenever an parent level exclude is specified with dot notation, the child field level excludes are overwritten. It would be great if they could be concatenated.

Here’s an example:

from marshmallow import fields, Schema

class FooChildSchema(Schema):
    boo = fields.String()
    far = fields.String()
    faz = fields.String()

class FooSchema(Schema):
    foo = fields.String()
    bar = fields.String()
    baz = fields.String()
    child = fields.Nested(FooChildSchema, exclude=('boo',))

obj = {
    'foo': 'foo',
    'bar': 'bar',
    'baz': 'baz',
    'child': {
        'boo': 'boo',
        'far': 'far',
        'faz': 'faz',
    },
}

serialized = FooSchema(exclude=('foo', 'child.faz')).dump(obj).data
print(serialized)

I expect :

{'child': {'far': 'far'}, 'baz': 'baz', 'bar': 'bar'}

instead, I get:

{'child': {'far': 'far', 'boo': 'boo'}, 'baz': 'baz', 'bar': 'bar'}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
deckar01commented, Apr 26, 2018

I will pick this back up now that #772 is fixed. Thanks @lafrech.

1reaction
timc13commented, May 8, 2018

@deckar01 don’t mean to be annoying - but hopefully you havent forgotten about this? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Javascript overwrite part of a nested object with object merging
I'm working on a JS project where I need to override some values in my object which contains nested objects ...
Read more >
Moving all files of nested folders to other folder but without ...
The mv recipe can overwrite files if you have two or more that have a name collision. If you want to avoid that...
Read more >
Configure and validate exclusions based on extension, name ...
Exclude files from Microsoft Defender Antivirus scans based on their file extension, file name, or location.
Read more >
Flattening a nested directory - Unix & Linux Stack Exchange
The -i makes mv ask before overwriting any duplicates; you can substitute -f to overwrite them without asking (or -n to not ask...
Read more >
Module | webpack - JS.ORG
Rule. object. A Rule can be separated into three parts — Conditions, Results and nested Rules. ... Exclude all modules matching any of...
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