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

Commit bf894d63 by Sascha Depold

minor bugfix

1 parent c457aaf1
Showing with 16 additions and 15 deletions
...@@ -51,13 +51,27 @@ SequelizeHelper = { ...@@ -51,13 +51,27 @@ SequelizeHelper = {
return result return result
}, },
valuesForUpdate: function(object, options) {
var actualValues = object.values,
result = []
options = options || {}
SequelizeHelper.Hash.forEach(actualValues, function(value, key) {
var dataType = object.table.attributes[key]
result.push([key, SequelizeHelper.SQL.transformValueByDataType(value, dataType)].join(" = "))
})
return result.join(options.seperator || ", ")
},
fieldsForInsertQuery: function(object) { fieldsForInsertQuery: function(object) {
return SequelizeHelper.Hash.keys(object.values).join(", ") return SequelizeHelper.Hash.keys(object.values).join(", ")
}, },
transformValueByDataType: function(value, dataType) { transformValueByDataType: function(value, dataType) {
if((value == null)||(typeof value == 'undefined')) if((value == null)||(typeof value == 'undefined')||((dataType.indexOf(Sequelize.INTEGER) > -1) && isNaN(value)))
return "NULL" return "NULL"
if(dataType.indexOf(Sequelize.FLOAT) > -1) if(dataType.indexOf(Sequelize.FLOAT) > -1)
...@@ -75,20 +89,6 @@ SequelizeHelper = { ...@@ -75,20 +89,6 @@ SequelizeHelper = {
return ("'" + value + "'") return ("'" + value + "'")
}, },
valuesForUpdate: function(object, options) {
var actualValues = object.values,
result = []
options = options || {}
SequelizeHelper.Hash.forEach(actualValues, function(value, key) {
var dataType = object.table.attributes[key]
result.push([key, SequelizeHelper.SQL.transformValueByDataType(value, dataType)].join(" = "))
})
return result.join(options.seperator || ", ")
},
hashToWhereConditions: function(conditions, attributes) { hashToWhereConditions: function(conditions, attributes) {
if(typeof conditions == 'number') if(typeof conditions == 'number')
return ('id = ' + conditions) return ('id = ' + conditions)
......
...@@ -338,6 +338,7 @@ SequelizeTable = function(sequelize, tableName, attributes) { ...@@ -338,6 +338,7 @@ SequelizeTable = function(sequelize, tableName, attributes) {
if(typeof newValues[attribute] != 'undefined') if(typeof newValues[attribute] != 'undefined')
self[attribute] = newValues[attribute] self[attribute] = newValues[attribute]
}) })
this.save(callback) this.save(callback)
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!