[MDEV-22411] Document JSON concepts as they are used and interpreted in MariaDB Created: 2020-04-29 Updated: 2020-04-29 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Documentation |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Ian Gilfillan |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||
| Description |
|
Documentation for JSON functions routinely refers to the concepts json_doc, path and value without describing them (or if such a description exists, it is not referred to). If the implication is that our definition is identical to JSON standard, in general it is not true, and even when it is, it can become wrong in future – the standard evolves and our implementation won't be able to keep up with it. It is also not user-friendly, as different concepts are described in different standards, e.g. JSON docs (texts), values etc. in JSON standard, while path in SQL standard. And definitions from JSON standard cannot be applied literally, they have to be interpreted in a certain way. Here is the simplest example. JSON standard says:
In our documentation, we call JSON texts "JSON documents". Like this:
So, if we take it all literally, each of these should be true:
But it is not so. From MariaDB perspective, the correct syntax would be
instead of
where json_text is what JSON standard specifies. So, when we try to run the above, we'll get
because it should really be
However, if we check other two examples, they will appear to be valid, which is even more confusing:
As explained by serg, it happens not because these are really valid JSON texts, but because MariaDB features implicit type conversion . It has already caused confusion among users and will likely cause more. I experienced it, too. JSON path is even worth, because in SQL standard it is the whole language. Obviously not all of it has been implemented, but which part has is impossible to guess. To summarize, I suggest
|