-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
multipleOf less than 1 doesn't validate with json_matches_schema
#67
Comments
This is a bug in the jsonschema crate used by pg_jsonschema. Specifically, this function first uses float types to find out if a float value is a multiple of another and only if the result is a NaN value it falls back to @johncmacy would you like to open a bug in the jsonschema repo? @Stranger6667 should be able to help you. |
The JSON Schema spec defines
And validation of numeric instances:
However, the spec does not require specific numeric representations (e.g., IEEE754 vs. decimal). This creates issues with The In any event, I think that most of the issues related to
Right now, there is a WIP PR that clarifies the matter. See also this issue. |
If |
Thank you both for the explanation. I understand better why it's a problem, but I still think this is a bug that needs to be fixed, not simply a need for better documentation. It sounds like there already are efforts to fix this - do you need me to create an issue, or is that redundant? FWIW, I'd put my vote in for this package (pg_jsonschema, the Postgres extension) to default to the decimal implementation. IMHO, that would result in the least amount of surprises. |
I think this issue is a good place to track the progress, hence no new issues are needed right now. I plan to consolidate all related information there + clarify a few moments with the JSON Schema folks, then will work on the implementation. |
Thanks, much appreciated! |
Bug report
Describe the bug
Number schemas with a
multipleOf
less than 1 don't validate. For example,17.2
should be valid against the schema{"type": "number","multipleOf": 0.1}
, butjson_matches_schema
returnsfalse
.I have verified the expected behavior using jsonschemavalidator.net.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Run the following in a Postgres database with the extension installed:
The above statement returns
false
.Expected behavior
The above statement should return
true
.Screenshots
N/A
System information
Additional context
N/A
The text was updated successfully, but these errors were encountered: