diff --git a/lib/client.js b/lib/client.js index a8fa07b..c7e613d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -23,9 +23,6 @@ var Client = function(config) { this.password = config.password || defaults.password; this.encoding = 'utf8'; var self = this; - this.connection.on('notify', function(msg) { - self.emit('notify', msg); - }) }; sys.inherits(Client, EventEmitter); @@ -111,6 +108,11 @@ p.connect = function() { self.activeQuery = null; } }); + + con.on('notice', function(msg) { + self.emit('notice', msg); + }) + }; p._pulseQueryQueue = function() { diff --git a/test/integration/client/notice-tests.js b/test/integration/client/notice-tests.js new file mode 100644 index 0000000..2aa0001 --- /dev/null +++ b/test/integration/client/notice-tests.js @@ -0,0 +1,11 @@ +var helper = require(__dirname + '/test-helper'); +test('emits notice message', function() { + var client = helper.client(); + + client.query('create temp table boom(id serial, size integer)'); + + assert.emits(client, 'notice', function(notice) { + assert.ok(notice != null); + client.end(); + }); +})