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: datetime2 rounding in mssql #7264

Merged
merged 1 commit into from
Feb 6, 2021
Merged

fix: datetime2 rounding in mssql #7264

merged 1 commit into from
Feb 6, 2021

Conversation

tgandrews
Copy link
Contributor

@tgandrews tgandrews commented Jan 10, 2021

Description of change

This upgrades the mssql driver to version 7 to resolve #3202. This
issue was created in the bulk insert test adding a datetime2 field
with a time of midnight.

v7 no longer allows numeric parameter names and was throwing an error
inside tedious but you can see that node-mssql is expecting a string.
https://github.com/tediousjs/node-mssql/blob/76585f973dd8cad48836fe302f99f67d47ff6129/lib/base/request.js#L101
Another user saw this issue in the comments of issue #3202.
#3202 (comment)

Stringifying the numeric parameter names before it enters the driver
resolves this issue.

Now all mssql tests pass locally once you provide additional config in
ormconfig.json locally required for a locally running docker instance
of mssql which uses a self signed certificate.

"extra": {
  "trustServerCertificate": true
}

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run lint passes with this change
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change - No new unit tests but the old MSSQL ones were failing
  • Documentation has been updated to reflect this change - N/A
  • The new commits follow conventions explained in CONTRIBUTING.md

@pleerock
Copy link
Member

Thank you for contribution! Are these changes backward compatible with previous mssql package versions?

@tgandrews
Copy link
Contributor Author

Are these changes backward compatible with previous mssql package versions?

Yes, the test suite doesn't pass without modification for mssql due to the #3202 as the test suite uses dates with times at midnight.

To test this with version 6 I needed to update a few tests.

  1. test/core/column-kinds/create-date-column/create-date-column.ts- updated time to 00:01:00
  2. test/core/column-kinds/update-date-column/update-date-column.ts - updated time to 00:01:00
  3. test/github-issues/499/issue-499.ts - Unable to update time as it is set internally to midnight as it is using a date column so test was disabled.
  4. test/github-issues/807/issue-807.ts - updated time to 00:01:00

But given the above modifications it all passes with this PR and no change to the mssql version.

@tgandrews
Copy link
Contributor Author

I also double checked the v6 JSDoc typing and that also states a string. https://github.com/tediousjs/node-mssql/blob/375419b590036bb8566bfc4452caa18b2ed444cd/lib/base/request.js#L100

And the same for v5
https://github.com/tediousjs/node-mssql/blob/01bc08f23aeaf81d27af9912e0b64dcfed7fd898/lib/base.js#L1075

So it seems it should have always been a string but never actually mattered until now

@tgandrews
Copy link
Contributor Author

@pleerock do you need anything more or are you waiting for v7 to be fully released?

@dsbert
Copy link
Contributor

dsbert commented Jan 26, 2021

I can confirm that we followed the same update path in our project to fix the same bug and have encountered the same error. Thank you @tgandrews

This upgrades the `mssql` driver to version 7 to resolve #3202. This
issue was created in the bulk insert test adding a datetime2 field
with a time of midnight.

v7 no longer allows numeric parameter names and was throwing an error
inside tedious but you can see that `node-mssql` is expecting a string.
https://github.com/tediousjs/node-mssql/blob/76585f973dd8cad48836fe302f99f67d47ff6129/lib/base/request.js#L101
Another user saw this issue in the comments of issue #3202.
#3202 (comment)

Stringifying the numeric parameter names before it enters the driver
resolves this issue.

Now all mssql tests pass locally once you provide additional config in
`ormconfig.json` locally required for a locally running docker instance
of mssql which uses a self signed certificate.
```json
"extra": {
  "trustServerCertificate": true
}
```
@tgandrews
Copy link
Contributor Author

This has been bumped to v7.0.0-beta.3

@AlexMesser AlexMesser merged commit 4711a71 into typeorm:master Feb 6, 2021
@AlexMesser
Copy link
Collaborator

thank you for contribution!

@tgandrews tgandrews deleted the fix-issue-with-node-mssql-7 branch February 6, 2021 20:08
v1d3rm3 pushed a commit to v1d3rm3/typeorm that referenced this pull request Jun 30, 2021
This upgrades the `mssql` driver to version 7 to resolve typeorm#3202. This
issue was created in the bulk insert test adding a datetime2 field
with a time of midnight.

v7 no longer allows numeric parameter names and was throwing an error
inside tedious but you can see that `node-mssql` is expecting a string.
https://github.com/tediousjs/node-mssql/blob/76585f973dd8cad48836fe302f99f67d47ff6129/lib/base/request.js#L101
Another user saw this issue in the comments of issue typeorm#3202.
typeorm#3202 (comment)

Stringifying the numeric parameter names before it enters the driver
resolves this issue.

Now all mssql tests pass locally once you provide additional config in
`ormconfig.json` locally required for a locally running docker instance
of mssql which uses a self signed certificate.
```json
"extra": {
  "trustServerCertificate": true
}
```

(cherry picked from commit 4711a71)
zshipleyTAG pushed a commit to Amherst-Development/typeorm that referenced this pull request Oct 17, 2022
This upgrades the `mssql` driver to version 7 to resolve typeorm#3202. This
issue was created in the bulk insert test adding a datetime2 field
with a time of midnight.

v7 no longer allows numeric parameter names and was throwing an error
inside tedious but you can see that `node-mssql` is expecting a string.
https://github.com/tediousjs/node-mssql/blob/76585f973dd8cad48836fe302f99f67d47ff6129/lib/base/request.js#L101
Another user saw this issue in the comments of issue typeorm#3202.
typeorm#3202 (comment)

Stringifying the numeric parameter names before it enters the driver
resolves this issue.

Now all mssql tests pass locally once you provide additional config in
`ormconfig.json` locally required for a locally running docker instance
of mssql which uses a self signed certificate.
```json
"extra": {
  "trustServerCertificate": true
}
```
afriedrichTAG added a commit to Amherst-Development/typeorm that referenced this pull request Oct 18, 2022
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.

node-mssql v6 incorrectly stores Dates
4 participants