Skip to content

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

Open

Description

@agarstang

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) {

Activity

  1. arthurschreiber commented on Oct 19, 2017

    @arthurschreiber
    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 [email protected] 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.

  2. arthurschreiber commented on Oct 19, 2017

    @arthurschreiber
    Collaborator

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

  3. chdh commented on Oct 19, 2017

    @chdh
    Collaborator

    @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 [email protected] or even later),

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

  4. arthurschreiber commented on Oct 19, 2017

    @arthurschreiber
    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. 😄

  5. added
    known issue
    on Dec 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    known issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions