Skip to content

Commit

Permalink
mssql: don't raise query-error twice (#4314)
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerjwatson committed Feb 25, 2021
1 parent 168f2af commit 6c3e7b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 0 additions & 4 deletions lib/dialects/mssql/index.js
Expand Up @@ -113,10 +113,6 @@ class Client_MSSQL extends Client {

queryBuilder() {
const b = new QueryBuilder(this);
const base = this;
b.on('query-error', function () {
base.emit('query-error', ...arguments);
});
return b;
}

Expand Down
7 changes: 6 additions & 1 deletion lib/execution/runner.js
Expand Up @@ -121,8 +121,13 @@ class Runner {
this.builder.emit('query', Object.assign({ __knexUid, __knexTxId }, obj));

const runner = this;
let queryPromise = this.client.query(this.connection, obj);
const queryContext = this.builder.queryContext();
// query-error events are emitted before the queryPromise continuations.
// pass queryContext into client.query so it can be raised properly.
if (obj !== null && typeof obj === 'object') {
obj.queryContext = queryContext;
}
let queryPromise = this.client.query(this.connection, obj);

if (obj.timeout) {
queryPromise = timeout(queryPromise, obj.timeout);
Expand Down

0 comments on commit 6c3e7b5

Please sign in to comment.