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

feat: Add jsonStrings configuration #2642

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

rubenmorim
Copy link

Added configuration to support jsonStrings.
Check #1072 for more details about this feat

Copy link

@wlarch wlarch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems perfectly legit to me. 💪

@wellwelwel wellwelwel linked an issue May 2, 2024 that may be closed by this pull request
Copy link

codecov bot commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.32%. Comparing base (e536b41) to head (fac1a87).
Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2642   +/-   ##
=======================================
  Coverage   90.32%   90.32%           
=======================================
  Files          71       71           
  Lines       15727    15729    +2     
  Branches     1339     1342    +3     
=======================================
+ Hits        14206    14208    +2     
  Misses       1521     1521           
Flag Coverage Δ
compression-0 90.32% <100.00%> (+<0.01%) ⬆️
compression-1 90.32% <100.00%> (+<0.01%) ⬆️
tls-0 89.85% <100.00%> (+<0.01%) ⬆️
tls-1 90.15% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wellwelwel
Copy link
Collaborator

wellwelwel commented May 2, 2024

Hey, @rubenmorim. Thanks 🚀


I believe the changes also fit the binary parser:

return 'JSON.parse(packet.readLengthCodedString("utf8"));';


For typings, we can include the option jsonStrings to node-mysql2/typings/mysql/lib/Connection.d.ts:

{
  jsonStrings?: boolean;
}

Also, we could have a basic test for execute and query. What do you think? 🙋🏻‍♂️
For example, something like:

SELECT CAST('{"test": true}' AS JSON) AS json_result;

@sidorares
Copy link
Owner

lgtm, in addition to @wellwelwel comments - maybe also add a bit of documentation somewhere in https://github.com/sidorares/node-mysql2/tree/master/website/docs/documentation

@wellwelwel wellwelwel removed needs documentation needs typings Typings for new features labels May 6, 2024
@wellwelwel
Copy link
Collaborator

wellwelwel commented May 13, 2024

The added documentation also closes:

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

Successfully merging this pull request may close these issues.

Provide an option to disable JSON parsing
4 participants