fix: "hasMany" only insert one row(#5220)
when there's no primary keys, we should append elems
This commit is contained in:
parent
f7b52bb649
commit
7abd781f45
@ -206,8 +206,8 @@ func SaveAfterAssociations(create bool) func(db *gorm.DB) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheKey := utils.ToStringKey(relPrimaryValues)
|
cacheKey := utils.ToStringKey(relPrimaryValues...)
|
||||||
if len(relPrimaryValues) != len(rel.FieldSchema.PrimaryFields) || !identityMap[cacheKey] {
|
if len(relPrimaryValues) == 0 || len(relPrimaryValues) != len(rel.FieldSchema.PrimaryFields) || !identityMap[cacheKey] {
|
||||||
identityMap[cacheKey] = true
|
identityMap[cacheKey] = true
|
||||||
if isPtr {
|
if isPtr {
|
||||||
elems = reflect.Append(elems, elem)
|
elems = reflect.Append(elems, elem)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user