dolt
dolt copied to clipboard
JSON values containing non-JSON data (datetime, decimal, etc) cause error when used in <=> comparisons
In MySQL, the JSON datatype is allowed to wrap data that does not typically appear in JSON, including other builtin types like decimals, datetime, etc.
Dolt appears to coerce these values into strings when inserted into a table (see https://github.com/dolthub/dolt/issues/7199)
Integers, meanwhile, get coerced into floats because typical JSON only has a single number type.
However, it's possible to do comparisons on these values before they're inserted into a table. This can cause errors.
Example:
CREATE TABLE test (j json);
insert into test VALUES ('{ "key": 1.0 }');
select * from test where JSON_OBJECT("key", 0.0) < test.j;
MySQL:
+--------------+
| j |
+--------------+
| {"key": 1.0} |
+--------------+
Dolt:
invalid type: 0