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

fix: correct SmallDateTime upper bound range #1621

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rockymadden
Copy link

Before submitting a PR :

  1. Ensure your fork is created from master branch of the repository.
  2. Run npm install in the root folder.
  3. After bug fix/code change, ensure all the existing tests and new tests (if any) pass (npm run-script test-all). During development, to run individual test use node_modules/nodeunit test/<test_file.js> -t <test_name>.
  4. Build the driver (npm run build).
  5. Run eslint and flow typechecker (npm run lint).
  6. Run commitlint (node_modules/.bin/commitlint --from origin/master --to HEAD). Refer commit conventions and commit rules.

Thank you for Contributing!

Copy link
Contributor

@MichaelSun90 MichaelSun90 left a comment

Choose a reason for hiding this comment

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

Thanks for catching this and puttying in the effort for raising this PR. I just had a comment for remove an unnecessary test case, and it should be good to go. 🙇

test/unit/data-type.js Outdated Show resolved Hide resolved
@rockymadden rockymadden marked this pull request as ready for review May 10, 2024 14:08
Copy link
Contributor

@MichaelSun90 MichaelSun90 left a comment

Choose a reason for hiding this comment

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

Sorry, I may put my pervious comment at a confusing line. I added new comment, and hope it will clear things up.


assert.throws(() => {
TYPES.SmallDateTime.validate(new Date('June 1, 2079'));
}, TypeError, 'Out of range.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, Maybe I was being confusing on this. I mean that the test case that test against May 7, 2079 can be removed since it this date is a valid smalldatetime value. Your original modification that change June 1, 2079 to June 7, 2079 is still a valid modification we should keep that.
Basically this test will looks like this:

describe('.validate', function() {
    it.only('returns a TypeError for dates that are out of range', function() {
      assert.throws(() => {
        TYPES.SmallDateTime.validate(new Date('Dec 31, 1889'));
      }, TypeError, 'Out of range.');

      assert.throws(() => {
        TYPES.SmallDateTime.validate(new Date('Jan 1, 2080'));
      }, TypeError, 'Out of range.');

      assert.throws(() => {
        TYPES.SmallDateTime.validate(new Date('June 7, 2079'));
      }, TypeError, 'Out of range.');
    });
  });

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.

None yet

2 participants