Skip to content

Commit 3bb9757

Browse files
committed
Make callback to pool.query optional
closes #585
1 parent 40eb738 commit 3bb9757

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ you spot any mistakes.
77
## HEAD
88

99
* Use indexOf instead of for loops removing conn from pool #611
10+
* Make callback to `pool.query` optional like `conn.query` #585
1011

1112
## v2.1.1 (2014-03-13)
1213

lib/Pool.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ Pool.prototype.query = function (sql, values, cb) {
128128
values = null;
129129
}
130130

131+
if (!cb) {
132+
// Ignore results and errors if no cb supplied; matches connection.query
133+
cb = function () {};
134+
}
135+
131136
var connection;
132137
var query = Connection.createQuery(sql, values, function (err, rows, fields) {
133138
connection.release();

test/integration/pool/test-query.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ pool.query('SELECT 1', function (err, _rows, _fields) {
88
rows = _rows;
99
fields = _fields;
1010

11-
pool.end();
11+
// Should work without error
12+
pool.query('SELECT SQL_ERROR');
13+
14+
process.nextTick(function () {
15+
pool.end();
16+
});
1217
});
1318

1419
process.on('exit', function () {

0 commit comments

Comments
 (0)