Skip to content

Commit abd1e94

Browse files
committed
PromisePool to always use the specified promises library
1 parent 5f65614 commit abd1e94

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

promise.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,15 +356,15 @@ PromisePool.prototype.execute = function(sql, values) {
356356
var corePool = this.pool;
357357
const localErr = new Error();
358358

359-
return new Promise(function(resolve, reject) {
359+
return new this.Promise(function(resolve, reject) {
360360
corePool.execute(sql, values, makeDoneCb(resolve, reject, localErr));
361361
});
362362
};
363363

364364
PromisePool.prototype.end = function() {
365365
var corePool = this.pool;
366366
const localErr = new Error();
367-
return new Promise(function(resolve, reject) {
367+
return new this.Promise(function(resolve, reject) {
368368
corePool.end(function(err) {
369369
if (err) {
370370
localErr.message = err.message;

test/integration/promise-wrappers/test-promise-wrappers.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,24 @@ function testObjParamsPool() {
307307
console.log(err);
308308
});
309309
}
310+
function testPromiseLibrary() {
311+
var pool = createPool(config);
312+
var promise = pool.execute({
313+
sql: 'select ?-? as ttt',
314+
values: [8, 5]
315+
});
316+
promise
317+
.then(function() {
318+
assert.ok(promise instanceof pool.Promise);
319+
})
320+
.then(function() {
321+
promise = pool.end();
322+
assert.ok(promise instanceof pool.Promise);
323+
})
324+
.catch(function(err) {
325+
console.log(err);
326+
});
327+
}
310328

311329
function testEventsPool() {
312330
var pool = createPool(config);
@@ -470,6 +488,7 @@ testObjParamsPool();
470488
testEventsPool();
471489
testChangeUser();
472490
testPoolConnectionDestroy();
491+
testPromiseLibrary();
473492

474493
process.on('exit', function() {
475494
if (skipTest) {

0 commit comments

Comments
 (0)