Skip to content

Event: columnMetadata delivers deprecated Types #886

Open

Description

@glitzner

I get a BITN type (id: 104) for a BIT data field (id: 50) in SQL Server 2017. The problem now is, that the delivered deprecated type cannot be used as a parameter in request.addParameter(), because BITN has no validation rules and leads to: TypeError: parameter.type.validate is not a function
This issue happens also with other types like DATEN, NUMERICN, etc.

From my point of view, it should be possible, that the same type can be used for parameters as we get from the metadata, if not, it's not possible to do automatic type validation.

my connection.option (if that makes a difference):
rowCollectionOnRequestCompletion: false,
rowCollectionOnDone: false,
useColumnNames : false,
useUTC: false,
encrypt: false

Activity

  1. arthurschreiber commented on Apr 7, 2019

    @arthurschreiber
    Collaborator

    Yeah, that's not great. 😞 We'll probabably have to properly implement and expose these types.

  2. irgijs commented on May 9, 2019

    @irgijs

    I also ran into this issue. I have created a script to reproduce the error. The output is 4 times 'IntN', whereas I expect the output to be ‘Int’, ‘SmallInt’, ‘TinyInt’ and ‘BigInt’.

    
    function connect() {
    	const config = {
    		server: 'localhost',
    		options: { encrypt: false },
    		authentication: {
    			type: 'default',
    			options: {
    				userName: 'USERNAME',
    				password: 'PASSWORD',
    			},
    		},
    	};
    
    	return new Promise((resolve, reject) => {
    		const connection = new Connection(config);
    
    		connection.on('connect', err => {
    			if (err) {
    				reject(err);
    			} else {
    				resolve(connection);
    			}
    		});
    	});
    }
    
    async function runStatement() {
    	const connection = await connect();
    
    	return new Promise((resolve, reject) => {
    		const stmt = 'select cast(1 as int) int, cast(1 as smallint ) smallint, cast(1 as tinyint ) tinyint, cast(1 as bigint ) bigint';
    
    		const request = new Request(stmt, (error, rowCount) => {
    			if (error) {
    				reject(error);
    			} else {
    				resolve(rowCount);
    			}
    		});
    
    		request.on('columnMetadata', (columns) => {
    			for (const column of columns) {
    				console.log(column.type.name);
    			}
    		});
    
    		connection.execSql(request);
    	});
    }
    
    runStatement();
    
  3. IanChokS commented on Aug 9, 2019

    @IanChokS
    Member

    @irgijs I'm currently looking into this!

  4. self-assigned this
    on Aug 14, 2019
  5. IanChokS commented on Aug 23, 2019

    @IanChokS
    Member

    #949 @glitzner @irgijs I've made a PR for this fix . It is currently under review, so take a look and see if this is the change you were hoping for! :)

  6. added
    Fix in current PR
    Action Required
    on Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Action RequiredFix in current PR

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions