不要怂,就是干,撸起袖子干!

Commit 10376a7d by Daniel Durante

Merge pull request #892 from durango/devdep

Cleaned up the postgres connector-manager/query code, updated node-postg...
2 parents 3a46e499 d4e89504
......@@ -19,9 +19,9 @@ module.exports = (function() {
// set pooling parameters if specified
if (this.pooling) {
this.pg.defaults.poolSize = this.config.pool.maxConnections
this.pg.defaults.poolIdleTimeout = this.config.pool.maxIdleTime
this.pg.defaults.reapIntervalMillis = this.config.pool.reapInterval || 1000
this.pg.defaults.poolSize = this.config.pool.maxConnections || 10
this.pg.defaults.poolIdleTimeout = this.config.pool.maxIdleTime || 30000
this.pg.defaults.reapIntervalMillis = this.config.pool.reapInterval || 1000
}
this.disconnectTimeoutId = null
......@@ -142,7 +142,9 @@ module.exports = (function() {
}
if (this.client) {
this.client.end.bind(this.client)
// Closes a client correctly even if we have backed up queries
// https://github.com/brianc/node-postgres/pull/346
this.client.on('drain', this.client.end.bind(this.client))
}
this.isConnecting = false
......
......@@ -20,34 +20,34 @@ module.exports = (function() {
Query.prototype.run = function(sql) {
this.sql = sql
var self = this
, receivedError = false
, query = this.client.query(sql)
, rows = []
if (this.options.logging !== false) {
this.options.logging('Executing: ' + this.sql)
}
var receivedError = false
, query = this.client.query(sql)
, rows = []
query.on('row', function(row) {
rows.push(row)
})
query.on('error', function(err) {
receivedError = true
this.emit('error', err, this.callee)
}.bind(this))
self.emit('error', err, self.callee)
})
query.on('end', function() {
this.emit('sql', this.sql)
self.emit('sql', self.sql)
if (receivedError) {
return
}
onSuccess.call(this, rows, sql)
}.bind(this))
onSuccess.call(self, rows, sql)
})
return this
}
......
......@@ -51,7 +51,7 @@
"devDependencies": {
"sqlite3": "~2.1.12",
"mysql": "~2.0.0-alpha8",
"pg": "~2.3.1",
"pg": "~2.6.0",
"watchr": "~2.4.3",
"yuidocjs": "~0.3.36",
"chai": "~1.7.2",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!