dolt icon indicating copy to clipboard operation
dolt copied to clipboard

Casting json to string doesn't escape double quotes in keys/values

Open nicktobey opened this issue 3 weeks ago • 0 comments

MySQL:

mysql> select cast(JSON_OBJECT('key"with"quotes', 1) as char);

+--------------------------+
| cast(@a as char)         |
+--------------------------+
| {"key\"with\"quotes": 1} |
+--------------------------+
1 row in set (0.00 sec)

mysql> select cast(cast(JSON_OBJECT('key"with"quotes', 1) as char) as json);

+---------------------------------------------------------------+
| cast(cast(JSON_OBJECT('key"with"quotes', 1) as char) as json) |
+---------------------------------------------------------------+
| {"key\"with\"quotes": 1}                                      |
+---------------------------------------------------------------+
1 row in set (0.00 sec)

Dolt:

> select cast(JSON_OBJECT('key"with"quotes', 1) as char);

+-------------------------------------------------+
| cast(JSON_OBJECT('key"with"quotes', 1) as char) |
+-------------------------------------------------+
| {"key"with"quotes": 1}                          |
+-------------------------------------------------+
1 row in set (0.00 sec)

> select cast(cast(JSON_OBJECT('key"with"quotes', 1) as char) as json);

expression 'convert(convert(json_object('key"with"quotes',1), char), json)': couldn't convert to json: Invalid JSON text: invalid character 'w' after object key

nicktobey avatar Jun 11 '24 16:06 nicktobey