Fix replaceById for Oracle

This commit is contained in:
Loay Gewily 2017-02-22 11:32:43 -05:00 committed by loay
parent 22a39025a1
commit 5dc110afbf
1 changed files with 5 additions and 1 deletions

View File

@ -689,10 +689,14 @@ SQLConnector.prototype.update = function(model, where, data, options, cb) {
* @param {Function} cb The callback function
*/
SQLConnector.prototype._replace = function(model, where, data, options, cb) {
var self = this;
var stmt = this.buildReplace(model, where, data, options);
this.execute(stmt.sql, stmt.params, options, function(err, info) {
if (err) return cb(err);
if (info.affectedRows === 0) {
var affectedRows = self.getCountForAffectedRows(model, info);
var rowCount = typeof (affectedRows) === 'number' ?
affectedRows : info.affectedRows;
if (rowCount === 0) {
return cb(errorIdNotFoundForReplace(where.id));
} else {
return cb(null, info);