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

Commit 90bfe09b by Sascha Depold

fixed error handling misbehavior

1 parent e67e43c0
...@@ -34,4 +34,7 @@ ...@@ -34,4 +34,7 @@
# 0.3.0 # # 0.3.0 #
- added possibility to define class and instance methods for models - added possibility to define class and instance methods for models
- added import method for loading model definition from a file - added import method for loading model definition from a file
\ No newline at end of file
# 0.3.1 #
- added error handling when defining invalid database credentials
\ No newline at end of file
...@@ -151,15 +151,15 @@ Sequelize.prototype = { ...@@ -151,15 +151,15 @@ Sequelize.prototype = {
}, },
query: function(queryString, callback) { query: function(queryString, callback) {
var fields = [] var fields = [],
var values = [] values = [],
var self = this self = this,
var connection = require(__dirname + "/../lib/nodejs-mysql-native/client").createTCPClient() connection = require(__dirname + "/../lib/nodejs-mysql-native/client").createTCPClient()
connection.auto_prepare = true connection.auto_prepare = true
connection connection
.auth(this.config.database, this.config.username, this.config.password) .auth(this.config.database, this.config.username, this.config.password)
.addListener("error", function(err) { callback(err) }) .addListener("error", function(err) { callback(null, null, err) })
.addListener('authorized', function() { .addListener('authorized', function() {
if(!self.options.disableLogging) if(!self.options.disableLogging)
Sequelize.Helper.log("Executing the query: " + queryString) Sequelize.Helper.log("Executing the query: " + queryString)
......
...@@ -88,14 +88,14 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o ...@@ -88,14 +88,14 @@ exports.SequelizeTable = function(Sequelize, sequelize, tableName, attributes, o
sequelize.query( sequelize.query(
Sequelize.sqlQueryFor( 'create', { table: table.tableName, fields: fields.join(', ') } ), Sequelize.sqlQueryFor( 'create', { table: table.tableName, fields: fields.join(', ') } ),
function(err) { if(callback) callback(table, err) } function(_, _, err) { if(callback) callback(table, err) }
) )
}, },
drop: function(callback) { drop: function(callback) {
sequelize.query( sequelize.query(
Sequelize.sqlQueryFor('drop', { table: table.tableName }), Sequelize.sqlQueryFor('drop', { table: table.tableName }),
function(err) { if(callback) callback(table, err) } function(_, _, err) { if(callback) callback(table, err) }
) )
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!