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

Commit 2d55a45b by Sascha Depold

fixed date bug

1 parent 4a61a0d5
Showing with 5 additions and 7 deletions
...@@ -87,13 +87,13 @@ Sequelize.prototype = { ...@@ -87,13 +87,13 @@ Sequelize.prototype = {
table.klass.prepareAssociations() table.klass.prepareAssociations()
}) })
if(SequelizeHelper.Hash.keys(this.tables).length == 0) if((SequelizeHelper.Hash.keys(this.tables).length == 0) && callback)
callback() callback()
else else
SequelizeHelper.Hash.forEach(tables, function(table) { SequelizeHelper.Hash.forEach(tables, function(table) {
table.klass.sync(function() { table.klass.sync(function() {
finished.push(true) finished.push(true)
if(finished.length == SequelizeHelper.Hash.keys(tables).length) if((finished.length == SequelizeHelper.Hash.keys(tables).length) && callback)
callback() callback()
}) })
}) })
...@@ -140,7 +140,7 @@ Sequelize.prototype = { ...@@ -140,7 +140,7 @@ Sequelize.prototype = {
SequelizeHelper.log("Executing the query: " + queryString) SequelizeHelper.log("Executing the query: " + queryString)
connection connection
.execute(queryString) .query(queryString)
.addListener('row', function(r){ values.push(r) }) .addListener('row', function(r){ values.push(r) })
.addListener('field', function(f){ fields.push(f)}) .addListener('field', function(f){ fields.push(f)})
.addListener('end', function() { .addListener('end', function() {
...@@ -152,7 +152,7 @@ Sequelize.prototype = { ...@@ -152,7 +152,7 @@ Sequelize.prototype = {
mapping[fields[i].name] = valueArray[i] mapping[fields[i].name] = valueArray[i]
result.push(mapping) result.push(mapping)
}) })
callback(result) if(callback) callback(result)
} }
}) })
connection.close() connection.close()
......
...@@ -80,7 +80,6 @@ SequelizeTable = function(sequelize, tableName, attributes) { ...@@ -80,7 +80,6 @@ SequelizeTable = function(sequelize, tableName, attributes) {
) )
}, },
// TODO: mysql library currently doesn't support MYSQL_DATE!!! look for fix
findAll: function(options, callback) { findAll: function(options, callback) {
// use the first param as callback if it is no object (hash) // use the first param as callback if it is no object (hash)
var _callback = (typeof options == 'object') ? callback : options var _callback = (typeof options == 'object') ? callback : options
...@@ -111,11 +110,10 @@ SequelizeTable = function(sequelize, tableName, attributes) { ...@@ -111,11 +110,10 @@ SequelizeTable = function(sequelize, tableName, attributes) {
) )
}, },
// TODO: mysql library currently doesn't support MYSQL_DATE!!! don't merge if fixed
sqlResultToObject: function(result) { sqlResultToObject: function(result) {
if(typeof result == undefined) return null if(typeof result == undefined) return null
var object = new table(SequelizeHelper.Hash.merge({createdAt: new Date(), updatedAt: new Date()}, result, true)) var object = new table(result)
object.id = result.id object.id = result.id
return object return object
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!