Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Fields with 'allow_null=True' should imply a default serialization value#5518
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
xordoquy commentedOct 20, 2017
shangxiao commentedOct 23, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Aside from discussions about whether flags should imply default values, I'd just would like to point out that if a serializer declares a field then a key for that field should unconditionally exist in the serialized output. The referenced change broke this contract for the first time. Although: I'd agree if this was rejected due to explicit vs implicit. Perhaps requiring a default to be declared in these cases? |
carltongibson commentedOct 25, 2017
@rpkilby What's the status here? I'm beginning to look at a 3.7.2 (say beginning of next week). Ta! |
rpkilby commentedOct 25, 2017
@carltongibson Basically, trying to figure out what the correct behaviorshould be here.
That all said:
Is this contract actually true, or is it an assumption made as a result of the previous behavior? Pinging@tomchristie for input here. |
rpkilby commentedOct 25, 2017
At this point, I'm kind of leaning towards accepting the PR. It allows correct serialization of fields when no object relation exists. However, when coupled with |
carltongibson left a comment
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.
OK. We're going to take this. Ultimately it seems entailed by the decisions we've already made, and we seemed to agree at each step.
The behaviour now seems consistent. There is (already) a slight change from earlier behaviour; addingdefault=None is recommended.
Maybe there's some weird combination of flags for which the behaviour is unexpected, but we need that pinned down in an actual code example if we are to proceed on it.
Even with such an example the answer might be, "use a custom field in that case" — we're not necessarily committed to covering every possible scenario.
For now, at least, we've spent long enough thinking about this one.
Thanks all.
rpkilby commentedDec 1, 2017
Just as a followup from#5639..
This statement is true,except for non-required fields. Quoting from the
|
The following currently fails as it's missing a
defaultvalue for serialization.The question is whether or not
allow_null=Trueshould implydefault=None.Thanks to@eschercode for pointing this outhere.
cc@xordoquy