Skip to content

feat: deprecate unexpected config option value types - #698

Merged
arthurschreiber merged 4 commits into
tediousjs:masterfrom
Hadis-Fard:boolean-type-deprecation
Feb 1, 2018
Merged

arthurschreiber merged 4 commits into
tediousjs:masterfrom
Hadis-Fard:boolean-type-deprecation

Conversation

@Hadis-Fard

Copy link
Copy Markdown

Added deprecation for boolean config types, as the changes in #692 are breaking change. Left the deprecation around encrypt to #695

@Hadis-Fard Hadis-Fard changed the title Boolean type deprecation feat: Config boolean type deprecation Jan 30, 2018
@arthurschreiber
arthurschreiber force-pushed the boolean-type-deprecation branch from 6c3fb7d to aecee91 Compare January 30, 2018 16:47
@arthurschreiber

Copy link
Copy Markdown
Collaborator

@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 null for config options where it does not make sense.

I also added deprecation warnings for passing null for config options where passing null will mean "do not send any value". This is important for config options tedious sets in the initial sql query payload, but a user might want to explicitly rely on the SQL Server configuration instead.

Would you mind taking a look? 🙇

@arthurschreiber arthurschreiber changed the title feat: Config boolean type deprecation feat: deprecate unexpected config option value types Jan 30, 2018
Comment thread src/connection.js Outdated
deprecateNullConfigValue('userName', config.userName);

if (config.password != undefined) {
deprecateNonStringConfigValue('userName', config.password);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

option name should be password here

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ugh - thanks! 🙇

Comment thread src/connection.js Outdated
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');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changing this might break an application if it relies on the error message, similar to columnNameReplacer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Comment thread src/connection.js

this.config.options.abortTransactionOnError = config.options.abortTransactionOnError;
}
deprecateNullFallbackToDefaultConfigValue('options.abortTransactionOnError', config.options.abortTransactionOnError);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Would be good to add TODO to check for null values in getInitialSql before pushing the value into options

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

👍 to deprecateNullFallbackToDefaultConfigValue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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?

Comment thread src/connection.js Outdated
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.');

@Hadis-Fard Hadis-Fard Jan 30, 2018 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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 😅

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yup! See my other responses further below! 👍

Comment thread src/connection.js Outdated
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');

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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. 👍

@arthurschreiber
arthurschreiber force-pushed the boolean-type-deprecation branch 3 times, most recently from 521b3e2 to 8a127d3 Compare January 31, 2018 08:54
@arthurschreiber
arthurschreiber force-pushed the boolean-type-deprecation branch from 8a127d3 to 0cb2aec Compare January 31, 2018 18:11
@Hadis-Fard

Copy link
Copy Markdown
Author

LGTM

@arthurschreiber

Copy link
Copy Markdown
Collaborator

@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
arthurschreiber merged commit b807646 into tediousjs:master Feb 1, 2018
@Hadis-Fard

Copy link
Copy Markdown
Author

@arthurschreiber I appreciate your contribution to this branch, and I just had to merge two remotes so it wasn't a pain 😺

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants