Your Question
Hello, I have some domain objects with cross-table relationships.
I have a 1-to-many relationship between two types.
When I retrieve them I am getting duplicate records.
A reproducer is here: https://github.com/manstis/gorm-playground/tree/duplicate-records
The reproducer is a simplification of my issue; but demonstrates it well.
I need to fetch a collection of records so using First() is not an option. I also need the all child objects populated.
The document you expected this should be explained
https://gorm.io/docs/has_many.html
Expected answer
Advice on how to return the correct number of records.
Comment From: a631807682
I didn't understand the problem here. If you use left join, you must return two records. If you only want to return one record, you can use preload to do it.
Comment From: manstis
Fair enough. I'm new to gorm and didn't know whether this was the expected behaviour. I'll close this issue. I had been experimenting with Preload(...) and reported the other issue around soft-deletes. Thank-you.