Skip to content

Commit

Permalink
Refactor named value support for PolymorphicType
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Oct 7, 2016
1 parent ab703af commit 39165d4
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 39165d4

Please sign in to comment.