sidorares / sidorares/node-mysql2
npm error when using typecast
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 4.4k
- Forks
- 680
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 59
Description
Hi,
using typecast
typeCast: function (field, next)
{
if (field.type === 'JSON')
{
let c = field.string("utf8"); <= this is causing the warning
if (c && c.toLowerCase() !== "[null]")
return (JSON.parse(c));
else
return [];
}
return next();
}
brings up npm error
typeCast: JSON column "MyColumnName" is interpreted as BINARY by default, recommended to manually set utf8 encoding: field.string("utf8")
For every query which contains a JSON_ARRAYAGG command.
This is spamming the logs so I really need to get rid of it
sorry do not know how to format the code correct
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The report does not name a file or test. Start by reproducing the warning with a typeCast callback and a query containing JSON_ARRAYAGG, then trace the MySQL JSON-column handling. Done means the intended JSON result still works without repeatedly spamming the logs with the encoding warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mysql, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100