Comparing version 0.8.3 to 0.8.4
@@ -136,7 +136,5 @@ //require the c++ bindings & export to javascript | ||
connection.on('_cmdStatus', function(status) { | ||
var meta = { | ||
}; | ||
meta.command = status.command.split(' ')[0]; | ||
meta.rowCount = parseInt(status.value); | ||
connection._lastMeta = meta; | ||
//set this here so we can pass it to the query | ||
//when the query completes | ||
connection._lastMeta = status; | ||
}); | ||
@@ -143,0 +141,0 @@ |
@@ -6,6 +6,14 @@ var EventEmitter = require('events').EventEmitter; | ||
var utils = require(__dirname + '/../utils'); | ||
var Result = require(__dirname + '/../result'); | ||
//event emitter proxy | ||
var NativeQuery = function(text, values, callback) { | ||
//TODO there are better ways to detect overloads | ||
EventEmitter.call(this); | ||
this.text = null; | ||
this.values = null; | ||
this.callback = null; | ||
this.name = null; | ||
//allow 'config object' as first parameter | ||
if(typeof text == 'object') { | ||
@@ -30,5 +38,3 @@ this.text = text.text; | ||
} | ||
if(this.callback) { | ||
this.rows = []; | ||
} | ||
this.result = new Result(); | ||
//normalize values | ||
@@ -40,4 +46,2 @@ if(this.values) { | ||
} | ||
EventEmitter.call(this); | ||
}; | ||
@@ -61,5 +65,5 @@ | ||
if(this.callback) { | ||
this.rows.push(row); | ||
this.result.addRow(row); | ||
} | ||
this.emit('row', row); | ||
this.emit('row', row, this.result); | ||
}; | ||
@@ -78,4 +82,5 @@ | ||
if(this.callback) { | ||
(meta || {}).rows = this.rows; | ||
this.callback(null, meta); | ||
this.result.command = meta.command.split(' ')[0]; | ||
this.result.rowCount = parseInt(meta.value); | ||
this.callback(null, this.result); | ||
} | ||
@@ -82,0 +87,0 @@ this.emit('end'); |
@@ -5,2 +5,5 @@ //result object returned from query | ||
var Result = function() { | ||
this.command = null; | ||
this.rowCount = null; | ||
this.oid = null; | ||
this.rows = []; | ||
@@ -11,3 +14,2 @@ }; | ||
var matchRegexp = /([A-Za-z]+) (\d+ )?(\d+)?/ | ||
@@ -14,0 +16,0 @@ |
{ "name": "pg", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"description": "PostgreSQL client - pure javascript & libpq with the same API", | ||
@@ -4,0 +4,0 @@ "keywords" : ["postgres", "pg", "libpq", "postgre", "database", "rdbms"], |
@@ -12,4 +12,5 @@ var helper = require(__dirname+"/test-helper"); | ||
var rows = []; | ||
query.on('row', function(row) { | ||
rows.push(row['name']) | ||
query.on('row', function(row, result) { | ||
assert.ok(result); | ||
rows.push(row['name']); | ||
}); | ||
@@ -21,3 +22,3 @@ query.once('row', function(row) { | ||
columnCount++; | ||
}; | ||
} | ||
if ('length' in row) { | ||
@@ -24,0 +25,0 @@ assert.lengthIs(row, columnCount, 'Iterating through the columns gives a different length from calling .length.'); |
@@ -85,3 +85,3 @@ var helper = require(__dirname + "/test-helper"); | ||
}); | ||
assert.ok(handled, "should have handlded rowDescritpion"); | ||
assert.ok(handled, "should have handlded rowDescription"); | ||
}); | ||
@@ -120,3 +120,3 @@ | ||
//this would never actually happen | ||
['dataRow','rowDescritpion', 'commandComplete'].forEach(function(msg) { | ||
['dataRow','rowDescription', 'commandComplete'].forEach(function(msg) { | ||
assert.equal(con.emit(msg), false, "Should no longer be picking up '"+ msg +"' messages"); | ||
@@ -123,0 +123,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
223484
6024
0
151