You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 :')
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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!
Beta Was this translation helpful? Give feedback.
All reactions