diff --git a/index.js b/index.js index 457d7f6c..70a90f57 100644 --- a/index.js +++ b/index.js @@ -89,6 +89,12 @@ Cursor.prototype.handleReadyForQuery = function() { this.state = 'done' } +Cursor.prototype.handleEmptyQuery = function(con) { + if (con.sync) { + con.sync() + } +}; + Cursor.prototype.handleError = function(msg) { this.state = 'error' this._error = msg diff --git a/package.json b/package.json index 8c26d80e..1096dee9 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "author": "Brian M. Carlson", "license": "MIT", "devDependencies": { - "pg.js": "~3.4.4", + "pg": "~6.0.0", "mocha": "~1.17.1" }, "dependencies": {} diff --git a/test/close.js b/test/close.js index 5f4f5bd9..df61319e 100644 --- a/test/close.js +++ b/test/close.js @@ -1,6 +1,6 @@ var assert = require('assert') var Cursor = require('../') -var pg = require('pg.js') +var pg = require('pg') var text = 'SELECT generate_series as num FROM generate_series(0, 50)' describe('close', function() { diff --git a/test/error-handling.js b/test/error-handling.js index 044c9624..fedee4b1 100644 --- a/test/error-handling.js +++ b/test/error-handling.js @@ -1,6 +1,6 @@ var assert = require('assert') var Cursor = require('../') -var pg = require('pg.js') +var pg = require('pg') var text = 'SELECT generate_series as num FROM generate_series(0, 4)' diff --git a/test/index.js b/test/index.js index 77b60cd2..8f04ccc2 100644 --- a/test/index.js +++ b/test/index.js @@ -1,6 +1,6 @@ var assert = require('assert') var Cursor = require('../') -var pg = require('pg.js') +var pg = require('pg') var text = 'SELECT generate_series as num FROM generate_series(0, 5)' diff --git a/test/no-data-handling.js b/test/no-data-handling.js index 9bcbef83..969df2d4 100644 --- a/test/no-data-handling.js +++ b/test/no-data-handling.js @@ -1,5 +1,5 @@ var assert = require('assert') -var pg = require('pg.js'); +var pg = require('pg'); var Cursor = require('../'); describe('queries with no data', function () { @@ -22,4 +22,15 @@ describe('queries with no data', function () { done() }) }); + + it('handles empty query', function (done) { + var cursor = new Cursor('-- this is a comment') + cursor = this.client.query(cursor) + cursor.read(100, function (err, rows) { + assert.ifError(err) + assert.equal(rows.length, 0) + done() + }) + }) + });