mirror of https://github.com/go-gorm/gorm.git
Refactor named value support for PolymorphicType
This commit is contained in:
parent
ab703afe97
commit
39165d4980
6
scope.go
6
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue