tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.23k stars 465 forks source link

a query to query view return empty result #1494

Closed ItsHeart closed 1 year ago

ItsHeart commented 1 year ago

Expected behaviour:

Correct query view with results returned.

Actual behaviour:

I used mssql to query and returned empty result, but running SQL directly can retrieve the correct result.

const getInfo = (req, res) => {
  let app = req.app;
  app.locals.db.query(
    String.format(app.locals.sql.getInfo, req.query.id),
    (err, recordset) => {
      if (err) {
        res.status(400).send(err);
        return;
      }
      res.status(200).send(recordset);
    }
  );
};

The query method can be passed during my testing of database operation, and the query results can be obtained.But the production environment is a slow view,I tried to change the requestTimeout in the configuration to 60000, but the result is still empty.

empty result exmple

{ recordsets: [ [] ], recordset: [], output: {}, rowsAffected: [ 0 ] }

Configuration:

module.exports = {
  user: "",
  password: "",
  database: "",
  server: "",
  options: {
    connectTimeout: 15000,
    requestTimeout: 60000,
    encrypt: false,
    trustServerCertificate: false,
  },
};

Software versions

dhensby commented 1 year ago

The GutHub issues are for reporting bugs and not support debugging application code. This library is capable of running SQL queries so I don't believe it is a bug.

You're not getting a timeout error, you're getting a result (be it an empty one) so it's not a timeout issue.

I'm not privvy to your database, queries, or other code that could be affecting things so I can't provide any meaningful support anyway.