From 7cd880712b9242cb002e7357e22b48b19a94ec75 Mon Sep 17 00:00:00 2001 From: Fabien Franzen Date: Fri, 15 Aug 2014 18:01:40 +0200 Subject: [PATCH] Handle toObject in updateAttributes Since one can call updateAttributes with any kind of properties (as opposed to save, which uses toObject internally), any objects that correspond to toObject should be handled as such. This is particularly the case with List objects, as used by embedsMany. --- lib/dao.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/dao.js b/lib/dao.js index 4ed71b3e..00fbf18c 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -1175,6 +1175,10 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb // Convert the properties by type inst[key] = data[key]; typedData[key] = inst[key]; + if (typeof typedData[key] === 'object' + && typeof typedData[key].toObject === 'function') { + typedData[key] = typedData[key].toObject(); + } } inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst),