forked from mirror/gorm
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 != "" {
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue