From 1eb6d79b978f67e96452d3b514977bcb34e18e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 28 Jan 2015 11:38:11 +0100 Subject: [PATCH] Fix crash in `id(model, property)` Before this change, an attempt to save a model instance with a dynamic property to a MySQL datasource crashed the application. This commit fixes the implementation of `id(model, property)` to correctly handle the case when the property is not described in the model definition. --- lib/connector.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/connector.js b/lib/connector.js index 54d4227..3eb6c79 100644 --- a/lib/connector.js +++ b/lib/connector.js @@ -104,10 +104,7 @@ Connector.prototype.idNames = function (model) { */ Connector.prototype.id = function (model, prop) { var p = this._models[model].properties[prop]; - if (!p) { - console.trace('Property not found: ' + model + '.' + prop); - } - return p.id; + return p && p.id; }; /**