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

sql.DateTime data type does not cast as per sql.DateTime2 #608

Open
agarstang opened this issue Aug 24, 2017 · 4 comments
Open

sql.DateTime data type does not cast as per sql.DateTime2 #608

agarstang opened this issue Aug 24, 2017 · 4 comments
Labels
known issue for any issue that has been reported or there's a PR with the fix

Comments

@agarstang
Copy link

Copying #185 from node-mssql.

days = Math.floor((parameter.value.getTime() - UTC_EPOCH_DATE.getTim
                                    ^
TypeError: undefined is not a function

In data-type.js you have missed to convert date string to object as you have done for DateTime2

if (parameter.value != null) {
      parameter.value = new Date(+parameter.value);  // this line is missing
       if (options.useUTC) {
@arthurschreiber
Copy link
Collaborator

The way we do type conversion in tedious is a mess, and really inconsistent.

I think this here is an actual bug (because it's raising a TypeError), and that's bad and needs to be fixed. But I'm not sure what a "good" fix is going to look like.

Long term (in tedious@3.x or even later), I want us to move away from doing any type conversion at all - if your application defines a parameter to be a DateTime, it should be your application's responsibility to pass a Date object and not a String or something else. And if you want to make use of SQLServer's type conversion, you should've specified a String parameter anyway.

@arthurschreiber
Copy link
Collaborator

/cc @chdh Because I think he might be interested in this discussion.

@chdh
Copy link
Collaborator

chdh commented Oct 19, 2017

@arthurschreiber

I want us to move away from doing any type conversion at all

This answers my question in #623.
What do you think about conversion from float to integer (same data type in JS, but not in SQL Server)? I think it's better not to convert at all and just verify that it's an integer number.

Long term (in tedious@3.x or even later),

I think it's not such a big change and it's important. I could write a PR if you like.

@arthurschreiber
Copy link
Collaborator

I think it's not such a big change and it's important. I could write a PR if you like.

It's a backwards incompatible change if we stop converting these values, so it should be a major version bump. We should not be afraid of major version bumps. 😄

@IanChokS IanChokS added the known issue for any issue that has been reported or there's a PR with the fix label Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
known issue for any issue that has been reported or there's a PR with the fix
Projects
None yet
Development

No branches or pull requests

4 participants