Skip to content
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

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

Open
nicktobey opened this issue Jun 11, 2024 · 0 comments
Open

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

nicktobey opened this issue Jun 11, 2024 · 0 comments
Labels
bug Something isn't working correctness We don't return the same result as MySQL

Comments

@nicktobey
Copy link
Contributor

nicktobey commented Jun 11, 2024

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
@timsehn timsehn added bug Something isn't working correctness We don't return the same result as MySQL labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness We don't return the same result as MySQL
Projects
None yet
Development

No branches or pull requests

2 participants