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)
|
markPopulated(field string)
|
||||||
markDepopulated(field string)
|
markDepopulated(field string)
|
||||||
newPopulationMap()
|
newPopulationMap()
|
||||||
|
getPopulated() map[string]bool
|
||||||
getRaw() any
|
getRaw() any
|
||||||
setRaw(raw any)
|
setRaw(raw any)
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,14 @@ func serializeIDs(input interface{}, isJson bool, populated map[string]bool, par
|
|||||||
break
|
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 {
|
if terr == nil {
|
||||||
ifc, ok := fv.Interface().(HasID)
|
ifc, ok := fv.Interface().(HasID)
|
||||||
if fv.Kind() == reflect.Slice {
|
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) {
|
func (d *Document) setRaw(raw any) {
|
||||||
d.raw = raw
|
d.raw = raw
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user