Skip to content

Commit

Permalink
Merge pull request #120 from M-TGH/fix/promise-check-void-connection
Browse files Browse the repository at this point in the history
fix: no longer error when checking .then on variables
  • Loading branch information
chrisradek authored Apr 22, 2019
2 parents 4787fdc + bbcdbd7 commit d2c7a15
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/mysql/lib/mysql_p.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function patchCreateConnection(mysql) {

mysql['createConnection'] = function patchedCreateConnection() {
var connection = mysql[baseFcn].apply(connection, arguments);
if (connection.then instanceof Function) {
if (connection && connection.then instanceof Function) {
connection = connection.then((result) => {
patchObject(result.connection);
return result;
Expand All @@ -55,7 +55,7 @@ function patchCreatePool(mysql) {

mysql['createPool'] = function patchedCreatePool() {
var pool = mysql[baseFcn].apply(pool, arguments);
if (pool.then instanceof Function) {
if (pool && pool.then instanceof Function) {
pool = pool.then((result) => {
patchObject(result.pool);
return result;
Expand Down Expand Up @@ -108,7 +108,7 @@ function patchGetConnection(pool) {
}

var result = pool[baseFcn].apply(pool, args);
if (result.then instanceof Function) return result.then(patchObject);
if (result && result.then instanceof Function) return result.then(patchObject);
else return result;
}
}
Expand Down

0 comments on commit d2c7a15

Please sign in to comment.