-
-
Notifications
You must be signed in to change notification settings - Fork 625
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
fix: typeCast string() parameters for JSON #1662
Conversation
would you be able to add a simple unit test, ideally in the context of json parsing ( e.i: create temp table with json column, insert data, read it using typeCast ) The test need to fail without proposed change to The change itself looks good to me. ( I wonder if we should be more helpful proactively? A warning in typeCast if the Also could you try to follow https://www.conventionalcommits.org/en/v1.0.0/ in commit messages @jyoonPro? |
@sidorares wilco. I'll try it tomorrow. |
@sidorares How should we warn the user? I'm not sure if I should use console.log() since no other part of the code seems to be using it. |
This is how we warn when the user node-mysql2/lib/commands/query.js Line 42 in 241cb10
|
string: function() { | ||
return _this.packet.readLengthCodedString(field.encoding); | ||
string: function(encoding = field.encoding) { | ||
if (field.columnType === Types.JSON && encoding === field.encoding) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you also check that encoding is not already utf8? I have a case where field.encoding
is, and passing utf8 explicitly still raises the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My current workaround for whoever is interested is to pass utf-8
instead of utf8
to get rid of the message.
#1661