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

Commit c50b1046 by Sascha Depold

Merge branch 'master' of git://github.com/1o1brian/sequelize into 1o1brian-master

2 parents f7493f6e 93063a21
Showing with 4 additions and 1 deletions
...@@ -49,6 +49,7 @@ module.exports = (function() { ...@@ -49,6 +49,7 @@ module.exports = (function() {
ConnectorManager.prototype.connect = function() { ConnectorManager.prototype.connect = function() {
var self = this var self = this
var emitter = new (require('events').EventEmitter)()
// in case database is slow to connect, prevent orphaning the client // in case database is slow to connect, prevent orphaning the client
if (this.isConnecting) { if (this.isConnecting) {
...@@ -64,7 +65,7 @@ module.exports = (function() { ...@@ -64,7 +65,7 @@ module.exports = (function() {
self.isConnecting = false self.isConnecting = false
if (!!err) { if (!!err) {
throw err emitter.emit('error', err)
} else if (client) { } else if (client) {
client.query("SET TIME ZONE 'UTC'") client.query("SET TIME ZONE 'UTC'")
.on('end', function() { .on('end', function() {
...@@ -84,6 +85,8 @@ module.exports = (function() { ...@@ -84,6 +85,8 @@ module.exports = (function() {
this.client = new this.pg.Client(uri) this.client = new this.pg.Client(uri)
this.client.connect(connectCallback) this.client.connect(connectCallback)
} }
return emitter
} }
ConnectorManager.prototype.disconnect = function() { ConnectorManager.prototype.disconnect = function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!