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 != "" { if relationship.PolymorphicType != "" {
value := scope.TableName() query = query.Where(fmt.Sprintf("%v = ?", scope.Quote(relationship.PolymorphicDBName)), relationship.PolymorphicValue)
if relationship.PolymorphicValue != "" {
value = relationship.PolymorphicValue
}
query = query.Where(fmt.Sprintf("%v = ?", scope.Quote(relationship.PolymorphicDBName)), value)
} }
scope.Err(query.Find(value).Error) scope.Err(query.Find(value).Error)
} }