From abd46961daa6159876ce20c2044e6ac18e2328b2 Mon Sep 17 00:00:00 2001 From: arlaneenalra Date: Tue, 4 Feb 2014 23:10:42 -0600 Subject: [PATCH] Use type converted data when writing back to database. This allows foreignKey types and other custom types to be converted into natvie values before writing them to the database. --- lib/dao.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dao.js b/lib/dao.js index 3a8c4a18..2aa948a8 100644 --- a/lib/dao.js +++ b/lib/dao.js @@ -847,6 +847,7 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb var inst = this; var Model = this.constructor var model = Model.modelName; + var typedData = {}; if (typeof data === 'function') { cb = data; @@ -873,9 +874,10 @@ DataAccessObject.prototype.updateAttributes = function updateAttributes(data, cb for (var key in data) { inst[key] = data[key]; + typedData[key] = inst.__data[key]; } - inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst), inst.constructor._forDB(data), function (err) { + inst._adapter().updateAttributes(model, getIdValue(inst.constructor, inst), inst.constructor._forDB(typedData), function (err) { if (!err) { // update $was attrs for (var key in data) {