`fields.Nested` missing in the request returns an empty list `[]`
See original GitHub issueHi, I would like to report a weird behavior I’ve stumbled upon. Consider we have the following schemas…
import marshmallow as ma
class OuterSchema(ma.Schema):
outer_field_one = ma.fields.Str()
outer_field_two = ma.fields.Str()
outer_field_three = ma.fields.Nested('InnerSchema', many=True)
class InnerSchema(ma.Schema):
inner_field_one = ma.fields.Str()
inner_field_two = ma.fields.Str()
when I try to pass a request containing only the outer_field_one
, I tend to get both the outer_field_one
and outer_field_three
with second one containing an empty list []
. I’m expecting that since I didn’t include outer_field_three
in the request, it shouldn’t be included.
I tried to see if this behavior might be native to marshmallow
itself, and do the de-serializing myself, but apparently it returns the correct results, which contains only the outer_field_one
.
Was this behavior intentional?? thanks
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:10 (6 by maintainers)
Top Results From Across the Web
Return empty JSON object with Flask-Restful Nested field ...
This can be achieved by creating a custom field, like this: class NestedWithEmpty(Nested): """ Allows returning an empty dictionary if marshaled value is ......
Read more >Relation queries (Concepts) - Prisma
Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.
Read more >Specify nested and repeated columns in table schemas
For Source, in the Create table from field, select Empty table. In the Destination section, specify the following fields: For Dataset, select the...
Read more >Querying arrays with complex types and nested structures
Your source data often contains arrays with complex data types and nested structures. Examples in this section show how to change element's data...
Read more >Response marshalling - Flask-RESTPlus - Read the Docs
If for some reason your data object doesn't have an attribute in your fields list, you can specify a default value to return...
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
Thank you guys for reporting/fixing this. Just got hit by this and latest release works a treat.
Thanks guys–I’ve released 1.5.1 with the fix.