Skip to content

Commit

Permalink
fix(lib/yukari.js): add another condition branch with no insertId whe…
Browse files Browse the repository at this point in the history
…n insert
  • Loading branch information
XadillaX committed Mar 9, 2016
1 parent 8e26822 commit f82f624
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/yukari.js
Expand Up @@ -318,8 +318,8 @@ Yukari.prototype.insert = function(callback) {
} else {
// 有多个主键

for(var i = 0; i < self.$model.primaryKeys.length; i++) {
where[pk[0].name] = (self[pk[i].name] !== undefined) ?
for(var i = 0; i < pk.length; i++) {
where[pk[i].name] = (self[pk[i].name] !== undefined) ?
self[pk[i].name] : self[pk[i].column];
}

Expand All @@ -328,6 +328,11 @@ Yukari.prototype.insert = function(callback) {
self[ai.name] = row.insertId;
}
}
} else {
for(var i = 0; i < pk.length; i++) {
where[pk[i].name] = (self[pk[i].name] !== undefined) ?
self[pk[i].name] : self[pk[i].column];
}
}

self.$model.where(where).findOne(function(err, row) {
Expand Down

0 comments on commit f82f624

Please sign in to comment.