From 9eaeb9e3990e9f5a057d3c7d544af1bf26470c55 Mon Sep 17 00:00:00 2001 From: Pandaiolo Date: Fri, 17 Oct 2014 15:44:24 +0200 Subject: [PATCH] Fix HasOne PK on modelFrom instead of modelTo --- lib/relation-definition.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/relation-definition.js b/lib/relation-definition.js index cbb87653..0651ef8b 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -1417,7 +1417,7 @@ RelationDefinition.hasOne = function (modelFrom, modelTo, params) { params = params || {}; modelTo = lookupModelTo(modelFrom, modelTo, params); - var pk = modelTo.dataSource.idName(modelTo.modelName) || 'id'; + var pk = modelFrom.dataSource.idName(modelFrom.modelName) || 'id'; var relationName = params.as || i8n.camelize(modelTo.modelName, true); var fk = params.foreignKey || i8n.camelize(modelFrom.modelName + '_id', true); @@ -2748,4 +2748,4 @@ ReferencesMany.prototype.remove = function (acInst, cb) { } else { process.nextTick(function() { cb(null, ids); }); } -}; \ No newline at end of file +};