-
Notifications
You must be signed in to change notification settings - Fork 152
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
Fix schema problems #66
Conversation
_make_default_field
to work with a variaty of types.
_make_default_field
to work with a variaty of types.
This fixes cases like this, hooray!
But if Bar contains an Enum-field, that fails with:
|
@dsvensson Looks like an easy fix, I used Could you provide the code that made this error? |
@Peilonrayz Oh that was easy. It was indeed just that typo. Too much redacting, but I can provide a test case later today. There's also another test case that ought to be added, for list of classes where one field contains a list of classes. That didn't work before this branch. #57 . More or less extending the last decoder test in the test...nestedsomething..py. |
@dsvensson Yeah I had done that with another I've added the test you mention already - test & object. Note, you can reproduce this without the outer most datatype being a list. It's just that the library only allows decoding lists via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thank you so much for reporting the issue and providing this much needed fix! Also thank you for cleaning up the tests and versioning them. I appreciate it a lot.
thanks!
will address this separately
yep this makes sense for a future patch |
Released in 0.2.2 |
@lidatong It should be noted that this line should be changed to I was waiting for a test case to work against until I committed the fix. |
In light of #68 I have updated the code to fix #57, #58, #60, #65, #67 and #68. I have added relevant tests and ensured they pass in Python 3.6 and 3.7. (I've changed the code to allow skipping of the datetime tests.)
From this I have moved all schema code into
mm
so that the marshmallow code is contained. And this is basically just a re-write ofmm
. I've updatedapi
to accommodate these changes.Otherwise only
core
has been changed. This is because marshmallow now loads schema data into the relevant model. (This can be tested against with code in #58). I'm unsure how you'd want the data to be handled, and so I chose to return early so I don't mangle withcore
too. please verify this is the intended behavior.This should keep all the previous logic around options, most are in
schema
such as specifying a default, and handlingOptional
. The other special piece of logic is when creating a DC, I kept thefield_many
option. Otherwisebuild_type
now builds all the types you'd previously specified, and a couple more, in a recursive form, defaulting tofields.Field
and a warning.I would like to request that we change how you handle the
dataclasses_json.mm_field
so that if the value isNone
we generate one by default. This isn't something you did previously, and so I didn't change this.