diff --git a/index.js b/index.js index 042d697b..9f4bbf2b 100644 --- a/index.js +++ b/index.js @@ -84,6 +84,10 @@ Pool.prototype.connect = function (cb) { Pool.prototype.take = Pool.prototype.connect Pool.prototype.query = function (text, values, cb) { + if (typeof values === 'function') { + cb = values + values = undefined + } return new this.Promise(function (resolve, reject) { this.connect(function (err, client, done) { if (err) return reject(err) diff --git a/test/index.js b/test/index.js index a7772b61..ce4f5ef8 100644 --- a/test/index.js +++ b/test/index.js @@ -32,6 +32,16 @@ describe('pool', function () { }) }) + it('can run a query with a callback without parameters', function (done) { + const pool = new Pool() + pool.query('SELECT 1 as num', function (err, res) { + expect(res.rows[0]).to.eql({ num: 1 }) + pool.end(function () { + done(err) + }) + }) + }) + it('can run a query with a callback', function (done) { const pool = new Pool() pool.query('SELECT $1::text as name', ['brianc'], function (err, res) {