diff --git a/lib/relation-definition.js b/lib/relation-definition.js index 2aaa70b9..9279fc7e 100644 --- a/lib/relation-definition.js +++ b/lib/relation-definition.js @@ -1055,6 +1055,7 @@ RelationDefinition.hasOne = function (modelFrom, modelTo, params) { var relationMethod = relation.related.bind(relation) relationMethod.create = relation.create.bind(relation); relationMethod.build = relation.build.bind(relation); + relationMethod._targetClass = relationDef.modelTo.modelName; return relationMethod; } }); diff --git a/test/relations.test.js b/test/relations.test.js index 5f52b4c0..f091486d 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -658,6 +658,9 @@ describe('relations', function () { }); }); + it('should set targetClass on scope property', function() { + should.equal(Supplier.prototype.account._targetClass, 'Account'); + }); }); describe('hasAndBelongsToMany', function () {