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

Commit 6b5e1b23 by Daniel Durante

Merge pull request #845 from durango/posgres-single-con

Postgres was having trouble restablishing connections for non-pool clients closes #832
2 parents 4ee4558d ad10d9b6
...@@ -89,6 +89,7 @@ module.exports = (function() { ...@@ -89,6 +89,7 @@ module.exports = (function() {
if (!!err) { if (!!err) {
// release the pool immediately, very important. // release the pool immediately, very important.
done && done(err) done && done(err)
self.client = null
if (err.code) { if (err.code) {
switch(err.code) { switch(err.code) {
...@@ -122,8 +123,8 @@ module.exports = (function() { ...@@ -122,8 +123,8 @@ module.exports = (function() {
this.poolIdentifier = this.pg.pools.getOrCreate(uri) this.poolIdentifier = this.pg.pools.getOrCreate(uri)
this.poolIdentifier.connect(connectCallback) this.poolIdentifier.connect(connectCallback)
} else { } else {
if (!!this.client) { if (!!this.client && this.client.readyForQuery === true) {
connectCallback(null, this.client); connectCallback(null, this.client)
} else { } else {
//create one-off client //create one-off client
this.client = new this.pg.Client(uri) this.client = new this.pg.Client(uri)
......
...@@ -709,10 +709,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -709,10 +709,10 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
this.User.bulkCreate(data).success(function() { this.User.bulkCreate(data).success(function() {
self.User.findAll({order: 'id'}).success(function(users) { self.User.findAll({order: 'id'}).success(function(users) {
expect(users.length).to.equal(2) expect(users.length).to.equal(2)
expect(users[0].username).to.equal("Peter") expect(users[0].username).to.equal('Peter')
expect(parseInt(+users[0].createdAt/5000, 10)).to.equal(parseInt(+new Date()/5000, 10)) expect(parseInt(+users[0].createdAt/5000, 10)).to.be.closeTo(parseInt(+new Date()/5000, 10), 1.5)
expect(users[1].username).to.equal("Paul") expect(users[1].username).to.equal('Paul')
expect(parseInt(+users[1].createdAt/5000, 10)).to.equal(parseInt(+new Date()/5000, 10)) expect(parseInt(+users[1].createdAt/5000, 10)).to.be.closeTo(parseInt(+new Date()/5000, 10), 1.5)
done() done()
}) })
}) })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!