-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
typeCast does not work for the execute
method
#3368
Comments
Hi @joakimbeng - please read #1446 and linked issues, hope that will give you a context to explain current behavior and future plans |
This is occurring because the node-mysql2/lib/parsers/binary_parser.js Lines 184 to 185 in 568a6cf
An approach would be to check if the parserFn(`if (nullBitmaskByte${nullByteIndex} & ${currentFieldNullBit}) {`);
if (typeof options.typeCast === 'function') {
parserFn(`${lvalue} = options.typeCast(wrap(fields[${i}], packet), () => null);`);
} else {
parserFn(`${lvalue} = null;`);
}
parserFn('} else {'); Note
|
@wellwelwel I see! If it's such an easy fix I'm all for it! 😃 It would be greatly appreciated if you would release that fix! |
@joakimbeng, there is a check to ensure if node-mysql2/lib/parsers/binary_parser.js Lines 195 to 199 in 568a6cf
The idea for a fix follows the same idea I mentioned, but would require a small refactoring in the order of the logic.
Feel free to do so 🚀
|
I am unable to get the
typeCast
option to work at all for theexecute
method. I have tried configuring it both on the connection level and per query, but with no success.I have set up a minimal reproduction example here: https://github.com/joakimbeng/mysql2-bug
The reproduction repo uses mysql2 v3.12.0 and node v22.
Am I missing something or shouldn't the
typeCast
option work with both thequery
andexecute
methods since v3.9.0?The text was updated successfully, but these errors were encountered: