-
-
Notifications
You must be signed in to change notification settings - Fork 623
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
Add .value() method to the typeCast field wrapper #2607
Conversation
Thanks, @Parsonswy 🚀 There are some Sequelize traces on
|
A question: this PR would work as a Regardless of benchmark, do you think it's possible to make these modifications without "keeping" the breaking changes you mentioned in #1446 (comment)? For context: |
Also looks like what we currently pass as a second parameter ( "next()" function ) to a typeCast call is what we actually need from instead of typeCast: function (field, next) {
if (field.type === 'LONGLONG') {
return field.string() === '1';
}
return next();
}, we can have an example typeCast: function (field, getValue) {
const value = getValue();
if (field.type === 'LONGLONG') {
return value === '1';
}
return value;
}, And later we can deprecate mapValue: function (field, value) {
if (field.type === 'LONGLONG') {
return value === '1';
}
return value;
}, |
I don't think I understand the question. By "breaking change" I meant invoking Going forward, I don't think it is safe to use the
Hmm. Yes. I think this is totally possible with the current API and I just zeroed in on I think I can close this PR, but will wait for further comment. Maybe the benchmarks are useful? |
let's close
|
Any progress on this ? We need to update mysql2 package due to this security update. But we can't due to this bug sequelize/sequelize#17141 |
Although the main issue was opened in Sequelize, the issue seems closer to this #1446 (comment) than to Sequelize. Unfortunately I haven't been able to reproduce this behavior using MySQL2 only. Any help on this would be appreciated. |
I was a bit crude here and most or less copy pasted the
readCodeFor
methods that compile the parser and am open to other approaches.Another option I considered was modifying the compiled parser so that it could be invoked recursively, but I felt that was going to be a bit hacky since
wrap()
would need to be able to invoke the parser, but the parser is defined usingwrap
. It would avoid duplicating the switch statement though.I also included a simple benchmark that compares querying with default the default cast behavior, custom type cast with the current wrapper methods, and type cast using the added
.value()
method.These are the results on my machine against a local docker container with mysql 8.3.0.