Repository navigation
fix: validate date input format before further process - #907
MichaelSun90 wants to merge 37 commits into
Conversation
| ['2015/06/18 23:59:59', Buffer.from('03163a0b', 'hex')], | ||
| ]) { | ||
| var buffer = new WritableTrackingBuffer(16); | ||
| type.writeParameterData(buffer, { value: value }, { useUTC: false }); |
There was a problem hiding this comment.
Due to the changes introduced via #845, calling writeParameterData now requires passing a callback function as the last parameter. I think it'd be enough to pass an empty callback function (like () => {}) to fix the test failures here.
There was a problem hiding this comment.
I asked a dumb question. Never mind my previous message. I take a second look on the code, and somehow I missed all the callback function places holders that added to the other test cases.
This comment has been minimized.
This comment has been minimized.
886636c to
6d10757
Compare
Codecov Report
@@ Coverage Diff @@
## master #907 +/- ##
===========================================
+ Coverage 65.41% 78.91% +13.49%
===========================================
Files 86 86
Lines 4386 4386
Branches 793 793
===========================================
+ Hits 2869 3461 +592
+ Misses 1162 653 -509
+ Partials 355 272 -83
Continue to review full report at Codecov.
|
|
Lines 389 - 392 in src/bulk-load.ts needs to be updated. 'types' does not have 'validate' method. |
…teTypeissue # Conflicts: # src/bulk-load.ts # src/data-types/date.js # src/data-types/datetime.js # test/unit/data-type.js
| if ('Invalid Date' === time.toString()) { | ||
| throw new TypeError('Invalid date.'); | ||
| } |
There was a problem hiding this comment.
Can this even happen? The .validate method returns a TypeError if an invalid date was passed. 🤔
There was a problem hiding this comment.
Is the 'validate' method will parse the input value first, then try to validate the date then?
There was a problem hiding this comment.
Is there any case that "generateParameterData" can be called independently? is not, then I guess this check is indeed not necessary. 😓
There was a problem hiding this comment.
I removed the unnecessary checks here and in dateTime as well.
| const error = c.type.validate(row[i]); | ||
| if (error instanceof TypeError) { | ||
| throw error; | ||
| } |
There was a problem hiding this comment.
This is a breaking change, because validation for bulk loads has never happened before. I agree that we should make this change, but in a separate PR so we can have the version number bumped.
There was a problem hiding this comment.
I will make a separate PR for this
There was a problem hiding this comment.
A new PR is made # 1065. I have reverted changes from this PR.
| const buffer = Buffer.concat([...TYPES.Date.generateParameterData(parameter, { useUTC: false })]); | ||
| assert.deepEqual(buffer, Buffer.from('03163a0b', 'hex')); | ||
| }); | ||
| it('dateInputWithSlashSeparator', () => { |
There was a problem hiding this comment.
I will fix this, made a mistake in the test name
|
I think with the changes in #1065 and |
Fix the issue mentioned in #889.
If the input Date format is 'YYYY/MM/DD', the current logic directly call math floor on this value will return a wrong date as output.
Added some validation logic before pass through the input value. Also, added some error check for invalid date error.
Added test cases for these handled scenarios