Refactor named value support for PolymorphicType

This commit is contained in:
Jinzhu 2016-10-07 22:19:28 +08:00
parent ab703afe97
commit 39165d4980
1 changed files with 1 additions and 5 deletions

View File

@ -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)
}