-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
only
argument inconsistent between Nested(S, many=True) and List(Nested(S))
#946
Comments
For now I'm using following workaround: class ListFix(List):
@property
def only(self):
return getattr(self.container, 'only')
@only.setter
def only(self, new_options):
original_options = getattr(self.container, 'only', ())
if original_options:
new_options &= type(new_options)(original_options)
setattr(self.container, 'only', new_options)
class Child(Schema):
name = String()
age = Integer()
class Family(Schema):
children = ListFix(Nested(Child)) the option propagation code was taken from maybe apply option code (the part I have copied to ListFix property) should be moved to field? Edited: Just found a nasty side effect of my "fix" family = {'children': [
{'name': 'Tommy', 'age': 12},
{'name': 'Lily', 'age': 15},
]}
for family_schema in (
Family(),
Family(only=['children.name']),
Family2(),
Family2(only=['children.name']),
):
pprint(family_schema.dump(family).data) prints
|
Thanks @rooterkyberian . Let's continue discussion of this in #779. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
returns
tested with marshmallow 2.15.4
The same applies to
exclude
argument.The text was updated successfully, but these errors were encountered: