Repository navigation
feat: allow validating bulk load parameters - #1065
Conversation
|
@MichaelSun90 Can you add a test case for this? |
Codecov Report
@@ Coverage Diff @@
## master #1065 +/- ##
==========================================
- Coverage 81.35% 79.93% -1.42%
==========================================
Files 86 86
Lines 4413 4415 +2
Branches 806 802 -4
==========================================
- Hits 3590 3529 -61
- Misses 564 623 +59
- Partials 259 263 +4
Continue to review full report at Codecov.
|
|
Thanks for providing a test case! 🙇 I think we should also add a test case for streaming bulk loads? I have a hunch that the change will not work for streaming bulk loads in its current form. 🤔 |
| throw new TypeError('The "config.options.validateBulkLoadParameters" property must be of type boolean.'); | ||
| } | ||
|
|
||
| deprecate('This "validateBulkLoadParameters" property will be depercated in the next major version of `tedious`.'); |
There was a problem hiding this comment.
I am not sure that I suppose to add the message here. I thought that users may want to know that this property is going to be deprecated when they are actually using it which means that when "config.options.validateBulkLoadParameters !== undefined". However, I am not sure whether I am correct about this.
a6e36eb to
0fa4521
Compare
| try { | ||
| request.addRow({ columnName: 'Wrong Input' }); | ||
| } catch (err) { | ||
| assert.strictEqual(err.message, 'Invalid date.'); | ||
| } |
There was a problem hiding this comment.
I think this should use the assert.throws helper:
| try { | |
| request.addRow({ columnName: 'Wrong Input' }); | |
| } catch (err) { | |
| assert.strictEqual(err.message, 'Invalid date.'); | |
| } | |
| assert.throws(() => { | |
| request.addRow({ columnName: 'Wrong Input' }); | |
| }, TypeError, 'Invalid date.'); |
There was a problem hiding this comment.
Oh, sure. There are few other tests in this test file that also using strictEqual, should I also modify them as well?
There was a problem hiding this comment.
Nvm, those are under "\test\integration\bulk-load-test.js" 😅
|
|
||
| this.config.options.validateBulkLoadParameters = config.options.validateBulkLoadParameters; | ||
| } else { | ||
| deprecate('The default value for "config.options.validateBulkLoadParameters" will change from `false` to `true` in the next major version of `tedious`. Set the value to `true` or `false` explicitly to silence this message.'); |
There was a problem hiding this comment.
Will this be a better message ? "This "validateBulkLoadParameters" property will be deprecated in the next major version of tedious."
There was a problem hiding this comment.
I think we'll want this to be a 2 step process:
- First, we introduce the
validateBulkLoadParametersflag, but keep defaulting tofalse. (minor release) - Then, we switch the default to
true. (major release) - We deprecate setting the
validateBulkLoadParametersflag to anything buttrue. (minor release) - Eventually, we drop the
validateBulkLoadParametersflag. (major release)
| const error = c.type.validate(row[i]); | ||
|
|
||
| if (error instanceof TypeError) { | ||
| return callback(error); |
There was a problem hiding this comment.
Hi @arthurschreiber, since the error is not thrown here, we need additional handling for the error under "addRow" method, right?
|
Hi, was just about to report an issue but found this feature that looks like it will fix it. Compiled part: In the Node.js documentation this is mentioned: "Throwing an Error from within these methods or manually emitting an 'error' event results in undefined behavior." |
|
|
||
| it('should test stream bulk load', function(done) { | ||
| this.timeout(50000); | ||
| this.timeout(200000); |
There was a problem hiding this comment.
change this because of that this test always gives me a time out error. Increase this make the test pass.
This adds a new `validateBulkLoadParameters` connection option that allows toggling bulk load parameter validation. This new option defaults to `false`, but will emit a deprecation warning if not set, and will change its default to `true` in the future.
299252d to
bb176fd
Compare
|
🎉 This PR is included in version 9.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Validate function will report error is input data do not match the data type check. However, the current bulk logic does not expose this error. Added some logic to expose these errors.
Related issue: #889