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

Commit 96743a91 by Elliot Chong

Fixing query generation error when calling save() on an Instance

When the raw value of ```id``` is stored as ```identifier``` in ```save()``` an invalid query is returned from the ```QueryGenerator```.

i.e. - Without the fix, an UPDATE query looks like this:  
```UPDATE `Users` SET `gender`='male',`email`='updated@bar.com',`updatedAt`='2013-05-29 23:33:36',`createdAt`='2013-05-29 23:33:36' WHERE 2```  

The ```WHERE 2``` is not the desired behavior. If ```id``` is wrapped in an object then the correct query is generated:  
```UPDATE `Users` SET `gender`='male',`email`='updated@bar.com',`updatedAt`='2013-05-29 23:33:36',`createdAt`='2013-05-29 23:33:36' WHERE `id`=2```
1 parent 32fa3034
Showing with 1 additions and 1 deletions
......@@ -158,7 +158,7 @@ module.exports = (function() {
else if (this.isNewRecord) {
return this.QueryInterface.insert(this, this.QueryInterface.QueryGenerator.addSchema(this.__factory), values)
} else {
var identifier = this.__options.hasPrimaryKeys ? this.primaryKeyValues : this.id;
var identifier = this.__options.hasPrimaryKeys ? this.primaryKeyValues : { id: this.id };
if (identifier === null && this.__options.whereCollection !== null) {
identifier = this.__options.whereCollection;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!