fix nested refs not being recognized as "populated" during serialization
This commit is contained in:
parent
0ebe3a2a3a
commit
378b5d756a
@ -84,6 +84,7 @@ type IDocument interface {
|
||||
markPopulated(field string)
|
||||
markDepopulated(field string)
|
||||
newPopulationMap()
|
||||
getPopulated() map[string]bool
|
||||
getRaw() any
|
||||
setRaw(raw any)
|
||||
}
|
||||
|
@ -84,6 +84,14 @@ func serializeIDs(input interface{}, isJson bool, populated map[string]bool, par
|
||||
break
|
||||
}
|
||||
}
|
||||
if iidoc, ok := input.(IDocument); ok && !ip {
|
||||
for k1, v1 := range iidoc.getPopulated() {
|
||||
if k1 == descent || k1 == ft.Name {
|
||||
ip = v1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if terr == nil {
|
||||
ifc, ok := fv.Interface().(HasID)
|
||||
if fv.Kind() == reflect.Slice {
|
||||
@ -316,6 +324,10 @@ func (d *Document) newPopulationMap() {
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Document) getPopulated() map[string]bool {
|
||||
return d.populatedFields
|
||||
}
|
||||
|
||||
func (d *Document) setRaw(raw any) {
|
||||
d.raw = raw
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user