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

fix: typeCast string() parameters for JSON #1662

Merged
merged 4 commits into from
Nov 8, 2022
Merged

fix: typeCast string() parameters for JSON #1662

merged 4 commits into from
Nov 8, 2022

Conversation

jyoonPro
Copy link

@jyoonPro jyoonPro changed the title Fix issue $1661 Fix issue #1661 Oct 27, 2022
@sidorares
Copy link
Owner

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 lib/parsers/text_parser.js

The change itself looks good to me. ( I wonder if we should be more helpful proactively? A warning in typeCast if the string() is used without charset AND field type is JSON )

Also could you try to follow https://www.conventionalcommits.org/en/v1.0.0/ in commit messages @jyoonPro?

@jyoonPro
Copy link
Author

@sidorares wilco. I'll try it tomorrow.

@jyoonPro
Copy link
Author

@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.

@sidorares
Copy link
Owner

@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 awaits non-promise query ( also this is immediately followed by throw so maybe not the best example )

console.log(err);

@jyoonPro jyoonPro changed the title Fix issue #1661 fix: typeCast string() parameters for JSON Oct 31, 2022
@sidorares sidorares merged commit f4de5c3 into sidorares:master Nov 8, 2022
string: function() {
return _this.packet.readLengthCodedString(field.encoding);
string: function(encoding = field.encoding) {
if (field.columnType === Types.JSON && encoding === field.encoding) {
Copy link
Contributor

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.

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants