cancel
Showing results for 
Search instead for 
Did you mean: 

node.js driver: Result set with null values

Former Member
3,372

Hello, I've had this weird issue where my node server would sometimes crash when executing a query. I've narrowed it down where it only crashes when my result set has null values.

Am I mistaken?

sqlanywhere_conn.connect(sqlanywhere_conn_params, function(){
  sqlanywhere_conn.exec("select * from some_table", function(err, result){
  // Does not reach code here when returning NULL values
  });
});


Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

jeff_albion
Product and Topic Expert
Product and Topic Expert

UPDATE: The SQL Anywhere node.js driver on NPM has now been updated with version 1.0.1 that now resolves this issue: https://www.npmjs.org/package/sqlanywhere

> npm update sqlanywhere
npm http GET https://registry.npmjs.org/sqlanywhere
npm http 200 https://registry.npmjs.org/sqlanywhere
npm http GET https://registry.npmjs.org/sqlanywhere/-/sqlanywhere-1.0.1.tgz
npm http 200 https://registry.npmjs.org/sqlanywhere/-/sqlanywhere-1.0.1.tgz

>; sqlanywhere@1.0.1 install C:\\vendor\\nodejs\\node_modules\\sqlanywhere
> node build.js

Looking for binaries...
Binaries found! Install Complete!
sqlanywhere@1.0.1 node_modules\\sqlanywhere



Hello,

I believe you are correct and this is a bug. I can reproduce the crash with the following code against the SQL Anywhere demo database:

var sqlanywhere = require('sqlanywhere');
var conn = sqlanywhere.createConnection();
var cstr = { Server : 'demo',
             UserID : 'DBA',
             Password : 'sql'
           };

conn.connect(cstr, function( err ) {
    if( err ) {
        console.log( err );
        return;
    } 
    console.log( "Connected!" );

    // This returns values
    conn.exec("select top 3 * from contacts where customerID is not null", function(err, result){
      if ( err ) {
        console.log( err );
        return;
      }
      console.log("Result (no nulls): ", result);
    });

    // This doesn't / crashes
    conn.exec("select top 3 * from contacts where customerID is null", function(err, result){
      if ( err ) {
        console.log( err );
        return;
      }
      console.log("Result (with nulls): ", result);
    });

    conn.disconnect( function( err ) {
        console.log( "Connection Closed" );
    });
});


I see the folowing output:

> node test.js
Connected!
Result (no nulls):  [ { ID: 1,
    Surname: 'Hildebrand',
    GivenName: 'Jane',
    Title: 'ma',
    Street: '280 Washington St.',
    City: 'Kanata',
    State: 'CA',
    Country: 'USA',
    PostalCode: '94608',
    Phone: '5105551309',
    Fax: '5105554209',
    CustomerID: 119 },
  { ID: 2,
    Surname: 'Simmon',
    GivenName: 'Larry',
    Title: 'sa',
    Street: '343 Granville St.',
    City: 'Kitchener',
    State: 'TX',
    Country: 'USA',
    PostalCode: '77079',
    Phone: '7135558960',
    Fax: '7135559265',
    CustomerID: 332 },
  { ID: 3,
    Surname: 'Critch',
    GivenName: 'Susan',
    Title: 'pd',
    Street: '457 Center St.',
    City: 'Yale',
    State: 'WY',
    Country: 'USA',
    PostalCode: '01923',
    Phone: '5085554829',
    Fax: '5085553025',
    CustomerID: 220 } ]


And the return code of the nodejs process is -1073740777.

I have opened CR #764049 to address this issue. Thank you for the bug report.

Former Member
0 Kudos

Where can I track this issue? Any idea when this will be resolved? Thanks 🙂

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

If you wish to report/track/receive immediate updates/request a fix for an issue, you must have a technical support contract.

We already have a fix for the issue, and we hope to have an update on the npm shortly. I'll update this thread once I see it published.

Answers (0)