From 39165d498058a823126af3cbf4d2a3b0e1acf11e Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 7 Oct 2016 22:19:28 +0800 Subject: [PATCH] Refactor named value support for PolymorphicType --- scope.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scope.go b/scope.go index 494a6d76..8906ed5f 100644 --- a/scope.go +++ b/scope.go @@ -999,11 +999,7 @@ func (scope *Scope) related(value interface{}, foreignKeys ...string) *Scope { } if relationship.PolymorphicType != "" { - value := scope.TableName() - if relationship.PolymorphicValue != "" { - value = relationship.PolymorphicValue - } - query = query.Where(fmt.Sprintf("%v = ?", scope.Quote(relationship.PolymorphicDBName)), value) + query = query.Where(fmt.Sprintf("%v = ?", scope.Quote(relationship.PolymorphicDBName)), relationship.PolymorphicValue) } scope.Err(query.Find(value).Error) }