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
Implement mapBinding mssql dialect option #5292
Implement mapBinding mssql dialect option #5292
Conversation
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.
Why only MsSQL dialect ?
lib/dialects/mssql/index.js
Outdated
} | ||
|
||
return Driver.TYPES.Int; | ||
return [binding, Driver.TYPES.Int]; | ||
} | ||
default: { | ||
// if (binding === null || typeof binding === 'undefined') { | ||
// return tedious.TYPES.Null; | ||
// } |
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.
can we remove this comment (not in your PR, but can be good to clean up)
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.
Why only MsSQL dialect ?
Each dialect within knex has it's own sauce for how to go from nodejs types to database specific types. Some even defer to the external library for handling the mapping itself (AFAIK). Executing this PR for all dialects would require each knex dialect/client to own this mapping itself. Would need someone that knows how to do that mapping for the other dialects to help take that on. I'm not sure this is as big of an issue with other dialects either.
can we remove this comment (not in your PR, but can be good to clean up)
Will do.
Documentation PR created. knex/documentation#440 |
Purpose (Fix: Issue #5268)
Allow users of knex to define custom mssql parameter value/type mapping through configuration. This is useful when having a mix of varchar/nvarchar types within your database. Or if you are simply looking to extend the db type mapping that exists within knex.
For example, having all strings map to
varchar
.Changes
mapBinding
type signature toMsSqlConnectionConfigBase
mapBinding
config option check and call to mssql dialect._typeForBinding
method to return the potentially mutated binding value to the calling codemapBinding
Documentation PR