Navigation Menu

Skip to content
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

Load schema with only=str gives empty UnmarshalResult #13

Closed
erlingbo opened this issue Oct 23, 2015 · 4 comments
Closed

Load schema with only=str gives empty UnmarshalResult #13

erlingbo opened this issue Oct 23, 2015 · 4 comments

Comments

@erlingbo
Copy link

When using a schema with the only attribute set to a string, the load method returns UnmarshalResult without errors nor data.

class MySchema(Schema):
    class Meta:
        fields = ('pk',)

    pk = fields.String()

MySchema(only='pk').load('an_id1234')
MySchema(only='pk').load({'pk': 'an_id1234'})

Both return the same UnmarshalResult
UnmarshalResult(data={}, errors={})

Preferably the first should work, but the second could be used with a pre load method on the schema class.

Is there anything I have done wrong or is this a bug?

@jklapuch
Copy link

Change

 only="pk"

with

only=["pk"]

and the second will work. The first will return:

UnmarshalResult(data={}, errors={u'_schema': [u'Invalid input type.']})

@erlingbo
Copy link
Author

yes, it will, but then dump will give me a different result, and thus not solve my probem

@jklapuch
Copy link

Other then this?

MySchema(only=["pk"]).dump({'pk': u'an_id1234'})
Out: MarshalResult(data={'pk': u'an_id1234'}, errors={})

@erlingbo
Copy link
Author

I see that I posted this in the json-api repo. Should have been in the original marshmallow project. Will close this and reopen it in the correct project.

marshmallow-code/marshmallow#307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants