From f56df39be83fc149dbd6c13486fe1f829c907d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Thu, 10 Apr 2025 16:06:55 -0400 Subject: [PATCH] fix bug where result.Document.self != result --- query.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/query.go b/query.go index 7d202a8..0d6cab5 100644 --- a/query.go +++ b/query.go @@ -611,10 +611,18 @@ func (q *Query) Exec(result interface{}) { imodel, ok := cur.Interface().(IDocument) if ok { imodel.setExists(true) + imodel.SetSelf(imodel) doc.Elem().Index(i).Set(reflect.ValueOf(imodel)) } } } + + if idoc, ok := q.doc.(IDocument); ok { + idoc.SetSelf(result) + } + if rdoc, ok2 := result.(IDocument); ok2 { + rdoc.SetSelf(result) + } reflect.ValueOf(result).Elem().Set(reflect.ValueOf(q.doc).Elem()) q.done = true }