Select() scans the query results differently compared to Model().
With Model() missing pointer relations are represented as nil (as expected), but with Select() they are represented with their default zero value struct.
Example:
type Team struct {
Id int
Name string
}
type Account struct {
Id int
TeamId int
Team *Team `pg:"rel:has-one"`
}
// ---
// teams table is empty, so there aren't any active account-team relations.
// ---
account1 := &Account{}
db.Model(account1).Relation("Team").Limit(1).Select()
// Result: account1.Team is nil (as expected)
account2 := &Account{}
db.Model((*Account)(nil)).Relation("Team").Limit(1).Select(account2)
// Result: account2.Team is a zero Team{} struct
Thanks for the report - should be fixed in v10.5.1
Most helpful comment
Thanks for the report - should be fixed in v10.5.1