From 5dc110afbf5072d04451cc44344934b86c8958a0 Mon Sep 17 00:00:00 2001 From: Loay Gewily Date: Wed, 22 Feb 2017 11:32:43 -0500 Subject: [PATCH] Fix replaceById for Oracle --- lib/sql.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sql.js b/lib/sql.js index 2132a57..c9345a7 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -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);