mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
small refactorings
This commit is contained in:
parent
1b9ccf97e9
commit
7ce1ddeab5
@ -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);
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user