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

You need to sign in or sign up before continuing.
Commit 879f83cd by Jan Aagaard Meier

Merge branch 'master' of github.com:sequelize/sequelize

2 parents 37087559 a6ff98be
...@@ -90,8 +90,11 @@ module.exports = (function() { ...@@ -90,8 +90,11 @@ module.exports = (function() {
var config = self.config.replication.read[reads++] var config = self.config.replication.read[reads++]
connect.call(self, function (err, connection) { connect.call(self, function (err, connection) {
connection.queryType = 'read' if (connection) {
done(null, connection) connection.queryType = 'read'
}
done(err, connection)
}, config) }, config)
}, },
destroy: function(client) { destroy: function(client) {
...@@ -106,8 +109,11 @@ module.exports = (function() { ...@@ -106,8 +109,11 @@ module.exports = (function() {
name: 'sequelize-write', name: 'sequelize-write',
create: function (done) { create: function (done) {
connect.call(self, function (err, connection) { connect.call(self, function (err, connection) {
connection.queryType = 'write' if (connection) {
done(null, connection) connection.queryType = 'write'
}
done(err, connection)
}, self.config.replication.write) }, self.config.replication.write)
}, },
destroy: function(client) { destroy: function(client) {
......
...@@ -88,8 +88,11 @@ module.exports = (function() { ...@@ -88,8 +88,11 @@ module.exports = (function() {
var config = self.config.replication.read[reads++]; var config = self.config.replication.read[reads++];
connect.call(self, function (err, connection) { connect.call(self, function (err, connection) {
connection.queryType = 'read' if (connection) {
done(null, connection) connection.queryType = 'read'
}
done(err, connection)
}, config); }, config);
}, },
destroy: function(client) { destroy: function(client) {
...@@ -104,8 +107,11 @@ module.exports = (function() { ...@@ -104,8 +107,11 @@ module.exports = (function() {
name: 'sequelize-write', name: 'sequelize-write',
create: function (done) { create: function (done) {
connect.call(self, function (err, connection) { connect.call(self, function (err, connection) {
connection.queryType = 'write' if (connection) {
done(null, connection) connection.queryType = 'read'
}
done(err, connection)
}, self.config.replication.write); }, self.config.replication.write);
}, },
destroy: function(client) { destroy: function(client) {
...@@ -296,7 +302,6 @@ module.exports = (function() { ...@@ -296,7 +302,6 @@ module.exports = (function() {
} }
var connection = mysql.createConnection(connectionConfig); var connection = mysql.createConnection(connectionConfig);
connection.connect(function(err) { connection.connect(function(err) {
if (err) { if (err) {
switch(err.code) { switch(err.code) {
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
"mocha": "~1.13.0", "mocha": "~1.13.0",
"chai-datetime": "~1.1.1", "chai-datetime": "~1.1.1",
"sinon": "~1.7.3", "sinon": "~1.7.3",
"mariasql": "git://github.com/mscdex/node-mariasql.git", "mariasql": "0.1.20",
"chai-spies": "~0.5.1", "chai-spies": "~0.5.1",
"lcov-result-merger": "0.0.2", "lcov-result-merger": "0.0.2",
"istanbul": "~0.1.45", "istanbul": "~0.1.45",
......
...@@ -64,6 +64,22 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () { ...@@ -64,6 +64,22 @@ describe(Support.getTestDialectTeaser("Sequelize"), function () {
done() done()
}) })
}) })
it('triggers the error event when using replication', function (done) {
new Sequelize('sequelize', null, null, {
replication: {
read: {
host: 'localhost',
username: 'omg',
password: 'lol'
}
}
}).authenticate()
.complete(function(err, result) {
expect(err).to.not.be.null
done()
})
})
}) })
}) })
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!