diff --git a/association_test.go b/association_test.go index 51a61f09..6079454b 100644 --- a/association_test.go +++ b/association_test.go @@ -14,7 +14,7 @@ func TestHasOneAndHasManyAssociation(t *testing.T) { post := Post{ Title: "post 1", Body: "body 1", - Comments: []Comment{{Content: "Comment 1"}, {Content: "Comment 2"}}, + Comments: []*Comment{{Content: "Comment 1"}, {Content: "Comment 2"}}, Category: Category{Name: "Category 1"}, MainCategory: Category{Name: "Main Category 1"}, } diff --git a/scope.go b/scope.go index db26c677..c0e35f2e 100644 --- a/scope.go +++ b/scope.go @@ -25,6 +25,9 @@ type Scope struct { func (scope *Scope) IndirectValue() reflect.Value { if scope.indirectValue == nil { value := reflect.Indirect(reflect.ValueOf(scope.Value)) + if value.Kind() == reflect.Ptr { + value = value.Elem() + } scope.indirectValue = &value } return *scope.indirectValue diff --git a/structs_test.go b/structs_test.go index acd4cc74..95c1ea38 100644 --- a/structs_test.go +++ b/structs_test.go @@ -146,7 +146,7 @@ type Post struct { MainCategoryId int64 Title string Body string - Comments []Comment + Comments []*Comment Category Category MainCategory Category }