-
-
Notifications
You must be signed in to change notification settings - Fork 215
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
Improve correctness and error messages for JSON functions. #2517
Conversation
…or lookup, which is handled separately.) MySQL doesn't do this and neither should we.
…s JSON null, not SQL null.
…ON_CONTAINS, and JSON_CONTAINS_PATH. JSON_VALUE is the only function that always returns SQL NULL if the document is JSON NULL.
…JSON, or are the wrong type. They now more closely match MySQL by printing the name of the function and the position of the incorrect parameter.
…JSON types and strings should be accepted.
So actually, it turns out that the only function that has any exceptional behavior around null documents is JSON_VALUE, which always returns SQL NULL for lookups on a document that is JSON NULL. In all other cases, what we're seeing is the natural consequence of the fact that:
This PR now incorporates a couple of fixes that are just related enough that separating them into individual PRs would be a hassle:
There's another issue I encountered during this, which I documented but am not attempting to fix with this PR: dolthub/dolt#7905 |
Additional work is required for integration with Dolt. |
Additional work is required for integration with Dolt. |
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.
LGTM, i didn't individually check the errors against MySQL but the messages look more useful. I have also noticed weird path behavior, I haven't spent time trying to find an optimal solution but nudging in the right direction seems good.
MySQL doesn't do this and neither should we.
MySQL:
The only time we should be coercing a JSON-null document into SQL-null is for JSON_EXTRACT (for paths other than "$") and JSON_VALUE (for all paths). But these are already handled separately.