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

Fix 0 default values appearing as None #286

Merged
merged 1 commit into from
May 19, 2024
Merged

Conversation

nkakouros
Copy link
Contributor

@nkakouros nkakouros commented Apr 6, 2024

Consider the following json schema snippet to define a property:

{
    "type" : "number",
    "minimum" : 0,
    "maximum" : 1,
    "default": 0
}

The code that sets the default reads:

"__default__": clsdata.get("default") or clsdata.get("const"),

If the default is 0 as in the example above, then the right branch of the or will be selected and result to None.

@andrewbwm
Copy link

Full disclosure, @nkakouros and I work on the same project. But I independently ran into this bug and was about to create a similar pull request just to discover he had already done so. If this could be merged in it would be really helpful.

Thank you!

@cwacek cwacek merged commit cc604ea into cwacek:master May 19, 2024
cwacek added a commit that referenced this pull request May 19, 2024
cwacek added a commit that referenced this pull request May 20, 2024
We no longer override value in the LiteralValue constructor when default is set, because it turns out it screws up the values when we're actually setting a value to null.

This still appears to pass all tests, so maybe it was literally wrong.
cwacek added a commit that referenced this pull request May 20, 2024
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

Successfully merging this pull request may close these issues.

3 participants