Repository navigation
feat: deprecate unexpected config option value types - #698
Conversation
6c3fb7d to
aecee91
Compare
|
@Hadis-Fard I force-pushed this pull request with a set of changes to extend deprecations a bit further. This deprecates passing all sorts of incorrect types being passed for different config values. I also added deprecation warnings for passing I also added deprecation warnings for passing Would you mind taking a look? 🙇 |
| deprecateNullConfigValue('userName', config.userName); | ||
|
|
||
| if (config.password != undefined) { | ||
| deprecateNonStringConfigValue('userName', config.password); |
There was a problem hiding this comment.
option name should be password here
| if (config.options.datefirst) { | ||
| if (config.options.datefirst < 1 || config.options.datefirst > 7) { | ||
| throw new RangeError('DateFirst should be >= 1 and <= 7'); | ||
| throw new RangeError('options.datefirst must be a number >= 1 and <= 7'); |
There was a problem hiding this comment.
Changing this might break an application if it relies on the error message, similar to columnNameReplacer
There was a problem hiding this comment.
Ugh. Yeah, this kinda depends on whether we think error messages are something users can or will depend on. I like to believe it is not 😅 - but I might be wrong.
I agree on pulling this out into the other pull request for breaking changes.
|
|
||
| this.config.options.abortTransactionOnError = config.options.abortTransactionOnError; | ||
| } | ||
| deprecateNullFallbackToDefaultConfigValue('options.abortTransactionOnError', config.options.abortTransactionOnError); |
There was a problem hiding this comment.
Would be good to add TODO to check for null values in getInitialSql before pushing the value into options
There was a problem hiding this comment.
👍 to deprecateNullFallbackToDefaultConfigValue
There was a problem hiding this comment.
Would be good to add TODO to check for null values in getInitialSql before pushing the value into options
Yeah. Would you like to prepare a pull request for that?
| if (config.options.columnNameReplacer !== undefined) { | ||
| if (typeof config.options.columnNameReplacer !== 'function') { | ||
| throw new TypeError('options.columnNameReplacer must be a function or null.'); | ||
| throw new TypeError('options.columnNameReplacer must be a function.'); |
There was a problem hiding this comment.
this change might break an application if it relies on error message, i guess it's better to include it in breaking changes PR just be on the safe side 😅
There was a problem hiding this comment.
Yup! See my other responses further below! 👍
| if (config.options.packetSize) { | ||
| if (config.options.packetSize != undefined) { | ||
| if (config.options.packetSize <= 0 || config.options.packetSize >= 65536) { | ||
| throw new RangeError('Port must be > 0 and < 65536'); |
There was a problem hiding this comment.
Error is thrown for port number should be packetsize 😉 , also this is a breaking change, it's better to include it in breaking changes PR
There was a problem hiding this comment.
I wouldn't quite classify this as a breaking change (passing any other value here would make the connection fail), but you're right, let's just put it into the breaking changes pull request. 👍
521b3e2 to
8a127d3
Compare
8a127d3 to
0cb2aec
Compare
|
LGTM |
10303cf to
0cb2aec
Compare
|
@Hadis-Fard Sorry, I was mucking around with this branch (as can be seen by the force pushes I made), and I believe that caused you a bunch of trouble. 😓 I'll refrain from doing that in the future, as it just causes pain without a lot of gain. 🙇 |
|
@arthurschreiber I appreciate your contribution to this branch, and I just had to merge two remotes so it wasn't a pain 😺 |
Added deprecation for boolean config types, as the changes in #692 are breaking change. Left the deprecation around encrypt to #695