Skip to content

columnMetadata type.name not listed in TYPES #1050

Open

Description

@Avaq

Steps to reproduce

Running the following query:

SELECT * FROM [test]

Against the following table:

CREATE TABLE [test] (
  Foo int
);

What I expect

I expect the columnMetadata.type.name property to correspond to one of the types in tedious.TYPES.

What actually happened

The columnMetadata.type contains the following object:

{
  id: 38,
  type: 'INTN',
  name: 'IntN',
  declaration: [Function: declaration],
  writeTypeInfo: [Function: writeTypeInfo],
  writeParameterData: [Function: writeParameterData],
  validate: [Function: validate]
}

And TYPES.IntN is undefined. All types listed in TYPES have a similar interface to the columnMetadata.type, but it seems it does not contain all types that are being exposed to me.


After some further investigation, I accidentally found that an older version of Tedious had many more types available on TYPES, and the problem I'm describing would not have occurred.

There must be a reason these types were removed from TYPES, and so there must be some kind of upgrade path for me.

My use-case is that I'm doing runtime type checking in parts of my code, and I verify that any type names going through my database driver are acknowledged in the TYPES enum, and my code now raises warnings about the type names returned in query results.

Activity

  1. changed the title [-]responseMeta type.name not listed in TYPES[/-] [+]columnMetadata type.name not listed in TYPES[/+] on Feb 19, 2020
  2. Avaq commented on Feb 19, 2020

    @Avaq
    Author

    Scrolling through the release notes, I found release 6.0.0: https://github.com/tediousjs/tedious/releases/tag/v6.0.0

    This removes the following, long deprecated parameter types: [...] IntN [...]

    So seeing as they've been long deprecated, and actually removed some major versions ago, my new question becomes: Why am I still seeing them returned in query results?

  3. Avaq commented on Feb 19, 2020

    @Avaq
    Author

    In the removal commit I found the following comment:

    These are all internal and should not be used directly. -- b67b66f#diff-86a99e3e71fe5daba55af730db310ba0L120

    This hints to the reason for deletion from TYPES: You don't want users to access them directly.

    For my own use-case this is a little problematic, because it means I can't nicely model TypeName for runtime type checking by simply taking the keys of TYPES as enums.

    Is there another way to obtain all possible types that might be exposed to users?

  4. IanChokS commented on Feb 19, 2020

    @IanChokS
    Member

    I think I have a PR that addresses this issue #1031. I'll update the PR. @arthurschreiber should we move forward with this?

  5. arthurschreiber commented on Feb 19, 2020

    @arthurschreiber
    Collaborator

    @Avaq Types like IntN are a detail of the TDS protocol, and there's no reason a user would ever need to know about it. It always maps to a "concrete" type like tinyint, smallint, int or bigint. Unfortunately, as you encountered, we don't actually map IntN back to one of these proper types, and expose this internal detail to users.

    #1031 would fix this, and I'll see if we can get it merged sooner rather than later to solve this issue for you and others.

  6. Avaq commented on Feb 19, 2020

    @Avaq
    Author

    Thank you for the replies! I honestly had a look around before I created this issue, but did not notice #886 before. Perhaps I should close this as a duplicate?

  7. IanChokS commented on Feb 19, 2020

    @IanChokS
    Member

    I think its fine if we can keep this open until the PR gets merged.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions