[MDEV-11439] No data type JSON, but CAST(something AS JSON) pretends to work Created: 2016-12-01 Updated: 2017-02-14 Resolved: 2017-02-14 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | JSON |
| Affects Version/s: | 10.2 |
| Fix Version/s: | 10.2.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Alexey Botchkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | 10.2-rc, json-10.2 | ||
| Issue Links: |
|
||||||||
| Description |
|
I don't think it makes any sense. We don't even have format JSON, how can we pretend we can CAST to it? And it's not even a valid JSON text. |
| Comments |
| Comment by Elena Stepanova [ 2016-12-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
serg, Have you approved this?
How does it make any sense at all, and in what way it's compatible with MySQL?
More about "compatibility":
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2016-12-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
This pseudo-cast is for cases like
What should be the result be,
or
That is, what is the second argument of json_object — a string or a json? This pseudo-cast solves this. Although I would prefer a standard solution instead:
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2016-12-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
serg, so, why not reserve the "room" for the standard FORMAT JSON if there is no time to implement it, and in the spirit of our current endeavor to follow standard defaults, imply the default, which is, coincidentally, FORMAT JSON? It will be different from MySQL, but at least it won't be difficult to explain (assuming it's documented), and for once it will be better than MySQL (and MariaDB) does now, by returning the first variant, only in an uglier form of
Fake CAST goes against everything, not just common sense – it does not improve compatibility with MySQL because results and types are different anyway; it falls out of the standard which does not suggest any explicit CAST there; and it contradicts the definition of the function CAST itself, which is supposed to produce a result value of the specified type (not shape or format). | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2016-12-18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
I agree, I don't like CAST. The standard specifies that if FORMAT JSON is not specified, then the second argument of json_object is a string, unless it's an output of another function that returns JSON. So, I'd rather implement FORMAT JSON now. This is, basically, just a syntax sugar. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexey Botchkov [ 2017-02-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
http://lists.askmonty.org/pipermail/commits/2017-February/010687.html |