Skip to content
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

feat: add range error validation for datatypes #1594

Merged
merged 7 commits into from
Jan 31, 2024

Conversation

MichaelSun90
Copy link
Contributor

@MichaelSun90 MichaelSun90 commented Dec 4, 2023

Add range error check for datatypes:

  • date
  • datetime
  • datetime2
  • smalldatetime
  • datetimeoffset
  • money

Adds validate tests for datatypes:

  • Int
  • SmallInt
  • TinyInt

Referenced the changes from this PR: #1271 : fix: out-of-range date error handle
Referenced the changes from PR #815 for money validation

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (6a961b5) 78.24% compared to head (8598f04) 66.05%.

Files Patch % Lines
src/data-types/date.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/datetime.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/datetime2.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/datetimeoffset.ts 42.85% 2 Missing and 2 partials ⚠️
src/data-types/smalldatetime.ts 42.85% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1594       +/-   ##
===========================================
- Coverage   78.24%   66.05%   -12.19%     
===========================================
  Files          93       93               
  Lines        4821     4858       +37     
  Branches      921      932       +11     
===========================================
- Hits         3772     3209      -563     
- Misses        750     1245      +495     
- Partials      299      404      +105     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}

if (value < MIN_DATE || value > MAX_DATE) {
throw new TypeError('Out of range.');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be RangeError instead? 🤔

@@ -1,12 +1,18 @@
import { type DataType } from '../data-type';
import { ChronoUnit, LocalDate } from '@js-joda/core';
import { type InternalConnectionOptions } from '../connection';

import { Collation } from '../collation';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this work? 🤔

Suggested change
import { Collation } from '../collation';
import { type Collation } from '../collation';

@MichaelSun90 MichaelSun90 merged commit 19cb073 into master Jan 31, 2024
27 of 30 checks passed
@mShan0 mShan0 deleted the michael-DatatypeRangeCheck branch January 31, 2024 21:51
Copy link

🎉 This PR is included in version 16.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

KAMAELUA pushed a commit to KAMAELUA/tedious-decimal that referenced this pull request Apr 29, 2024
* chore: add range error validation for date types

* add validation tests for numbers

* remove only

* add money validation

* chore: remove un-needed types

---------

Co-authored-by: mShan0 <96149598+mShan0@users.noreply.github.com>
(cherry picked from commit 19cb073)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants