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.
This commit is contained in:
Fabien Franzen 2014-08-15 18:01:40 +02:00
parent 6ea6f19752
commit 7cd880712b
1 changed files with 4 additions and 0 deletions

View File

@ -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),