ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

string returned after date type requested #975

Closed enlazoCtrl closed 5 months ago

enlazoCtrl commented 5 months ago

I'm trying to ask for a date type data to manage dates in the app but the database is returning string type. Is that a normal behaviour? I've created a test enviroment to prove it with the lastest version -> "ibm_db": "^3.2.3" Using Node -> v16.19.1 Typescript -> "typescript": "^5.0.0" Informix -> v12.10.0

The expected behaviour is that if I ask for date type data to avialable to display date methods with the answer like so:

Test code ->

    let ibmdb = require('ibm_db');
    let connStr = "CONNECTION TO DATABASE";

    ibmdb.open(connStr, function (err, conn) {
        if (err) return console.log(err);

        conn.query('select current as date from table(set{1})', function (err: any, data: {date: Date}) {
            if (err) console.log(err);
            else {
                  console.log( 'date: ',typeof data[0].date)  //result expected -> Date    result given -> String
            };
            conn.close(function () {
                console.log('done');
            });
        });
    });
bimalkjha commented 5 months ago

@enlazoCtrl Yes, it is expected behavior since start. ibm_db returns date, time and timestamp column values as string. Check the test file https://github.com/ibmdb/node-ibm_db/blob/master/test/test-all-data-types.js#L22. Thanks.