-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
re escaping special chars in json values #2575
Comments
Hi @Reaster0 could you try to reduce your example to something self contained ( including initial schema and data ) that I can try to run and debug locally? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, i've found a weird behaviour,
when querying a table and converting it to a JSON_TABLE, if a textual row inside of it contain a \n, it will be re escaped (so it will be given as "\\n"), something that it don't do when querying non JSON_TABLE textual values
an example:
rawQuery(
SELECT * FROM JSON_TABLE(
(
SELECT content as json
FROM logs_related_files
WHERE log_id = ?
LIMIT 1
),
'$[*]' COLUMNS (
name VARCHAR(255) PATH '$.name',
content LONGTEXT PATH '$.content',
contentType VARCHAR(255) PATH '$.contentType'
)
) as files
WHERE name = ?
LIMIT 1 , [id, name])
.then((res) => {
if (res[0].length == 0)
return response.status(404).send("Not found");
return res[0][0];
})
.catch((e) => {
console.log(e.message);
return response.status(400).send(e.message);
});
in this case, even if in "content" the value is "this is a\ntest" (notice the \n)
and i can confirm it by running the exact same sql query using a mysql cli client
the driver will give me a content containing "this is a \\ntest" (notice the \\n)
this issue doesn't appear if i query a non JSON_TABLE value (i get a correct "this is a \ntest" using the driver)
so for now i'm running a replace on the result to reset the correct antislash value but i would prefer not to ducktape it :')
thanks for your hardwork!
The text was updated successfully, but these errors were encountered: