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

Commit d1b914f7 by Matt Broadstone

remove faulty logic in update code

1 parent 69dc2200
Showing with 18 additions and 20 deletions
...@@ -226,30 +226,28 @@ module.exports = (function() { ...@@ -226,30 +226,28 @@ module.exports = (function() {
var query; var query;
attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, false, options); attrValueHash = Utils.removeNullValuesFromHash(attrValueHash, false, options);
//very unique case for cascades, i generally don't approve for (var key in attributes) {
if(Object.keys(attrValueHash).length === 1 && attributes[Object.keys(attrValueHash)[0]].primaryKey){ var aliasKey = attributes[key].field || key;
this.sequelize.log('Updating a Primary Key is not supported in MSSQL, please restructure your query'); if (attributes[key].primaryKey && attrValueHash[aliasKey]) {
}else{ delete attrValueHash[aliasKey];
for(var key in attributes){
var aliasKey = attributes[key].field || key;
if(attributes[key].primaryKey && attrValueHash[aliasKey]){
delete attrValueHash[aliasKey];
}
if(attrValueHash[aliasKey] && attrValueHash[aliasKey].fn){
}
} }
if(!Object.keys(attrValueHash).length){
return ''; if (attrValueHash[aliasKey] && attrValueHash[aliasKey].fn) {
//return ['SELECT * FROM ', tableName, 'WHERE', this.getWhereConditions(where) + ';'].join(' ');
} }
query = [
SqlGenerator.updateSql(tableName, attrValueHash, attributes),
'WHERE',
this.getWhereConditions(where)
].join(' ') + ';';
} }
if (!Object.keys(attrValueHash).length) {
return '';
//return ['SELECT * FROM ', tableName, 'WHERE', this.getWhereConditions(where) + ';'].join(' ');
}
query = [
SqlGenerator.updateSql(tableName, attrValueHash, attributes),
'WHERE',
this.getWhereConditions(where)
].join(' ') + ';';
return query; return query;
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!