Nested excludes get overwritten
See original GitHub issueIt 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:
- Created 6 years ago
- Reactions:3
- Comments:8 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I will pick this back up now that #772 is fixed. Thanks @lafrech.
@deckar01 don’t mean to be annoying - but hopefully you havent forgotten about this? 😃