small refactorings

This commit is contained in:
brianc 2010-11-02 23:46:13 -05:00
parent 1b9ccf97e9
commit 7ce1ddeab5

View File

@ -58,7 +58,6 @@ p.connect = function() {
con.on('readyForQuery', function() {
self.readyForQuery = true;
self.pulseQueryQueue();
});
@ -189,31 +188,23 @@ p.prepare = function(connection) {
};
var noParse = function(val) {
return val;
};
p.onRowDescription = function(msg) {
var typeIds = msg.fields.map(function(field) {
return field.dataTypeID;
});
var noParse = function(val) {
return val;
};
this.converters = typeIds.map(function(typeId) {
return Client.dataTypeParser[typeId] || noParse;
this.converters = msg.fields.map(function(field) {
return Client.dataTypeParser[field.dataTypeID] || noParse;
});
};
//handles the raw 'dataRow' event from the connection does type coercion
p.onDataRow = function(msg) {
var fields = msg.fields;
var converters = this.converters || [];
var len = msg.fields.length;
for(var i = 0; i < len; i++) {
if(fields[i] !== null) {
fields[i] = this.converters[i] (fields[i]);
for(var i = 0; i < msg.fields.length; i++) {
if(msg.fields[i] !== null) {
msg.fields[i] = this.converters[i](msg.fields[i]);
}
}
msg.fields = fields;
this.emit('row', msg);
};