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

Commit d1b914f7 by Matt Broadstone

remove faulty logic in update code

1 parent 69dc2200
Showing with 7 additions and 9 deletions
...@@ -226,29 +226,27 @@ module.exports = (function() { ...@@ -226,29 +226,27 @@ 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){
this.sequelize.log('Updating a Primary Key is not supported in MSSQL, please restructure your query');
}else{
for(var key in attributes){
var aliasKey = attributes[key].field || key; var aliasKey = attributes[key].field || key;
if(attributes[key].primaryKey && attrValueHash[aliasKey]){ if (attributes[key].primaryKey && attrValueHash[aliasKey]) {
delete attrValueHash[aliasKey]; delete attrValueHash[aliasKey];
} }
if(attrValueHash[aliasKey] && attrValueHash[aliasKey].fn){
if (attrValueHash[aliasKey] && attrValueHash[aliasKey].fn) {
} }
} }
if(!Object.keys(attrValueHash).length){
if (!Object.keys(attrValueHash).length) {
return ''; return '';
//return ['SELECT * FROM ', tableName, 'WHERE', this.getWhereConditions(where) + ';'].join(' '); //return ['SELECT * FROM ', tableName, 'WHERE', this.getWhereConditions(where) + ';'].join(' ');
} }
query = [ query = [
SqlGenerator.updateSql(tableName, attrValueHash, attributes), SqlGenerator.updateSql(tableName, attrValueHash, attributes),
'WHERE', 'WHERE',
this.getWhereConditions(where) this.getWhereConditions(where)
].join(' ') + ';'; ].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!