Closed nitaigao closed 4 months ago
Both unique question object seem to have a pointer to a single underlying answers collection. I think this is the source of the duplication.
I think it's related to a change in this commit: https://github.com/go-rel/rel/commit/ea91f66ee9217dcdc924eec58fbfd3a8bb5ac788
Thanks for the detailed description!
I'm able to fix this in this PR: https://github.com/go-rel/rel/pull/365 can you verify if it's fixed your issue?
I think the main issue is because pointer is used when the same record is referenced multiple time without above fix, the following should work correctly:
type ScheduledQuestion struct {
ID int
QuestionID int
Question Question // <--- not using pointer here
}
I can confirm it's working nicely with the https://github.com/go-rel/rel/pull/365 fix
Thanks for looking into it so quickly, I really appreciate it.
Hi, firstly thanks for this awesome library.
There seems to be an issue with the preloading that has been introduced since rel 0.39.0. The issue causes the nested relations of a preload to be accidentally duplicated.
I discovered this when trying to upgrade from go v1.18 to v.22 which meant that I needed the latest REL to be compatible.
I have tried to investigate but it's not clear to me how to fix the problem.
Versions:
Here's a quick repro:
output:
This result should be: