diff --git a/gorm_test.go b/gorm_test.go index 014c383e..6a1ec247 100644 --- a/gorm_test.go +++ b/gorm_test.go @@ -1273,6 +1273,11 @@ func TestRelated(t *testing.T) { if len(emails) != 2 { t.Errorf("Should have two emails") } + var user1 User + db.Model(&user).Related(&user1.Emails) + if len(user1.Emails) != 2 { + t.Errorf("Should have two emails") + } var address1 Address db.Model(&user).Related(&address1, "BillingAddressId") @@ -1280,6 +1285,12 @@ func TestRelated(t *testing.T) { t.Errorf("Should get billing address from user correctly") } + user1 = User{} + db.Model(&address1).Related(&user1, "BillingAddressId") + if db.NewRecord(user1) { + t.Errorf("Should get user from address correctly") + } + var user2 User db.Model(&emails[0]).Related(&user2) if user2.Id != user.Id || user2.Name != user.Name {