From 1086009fce2796a205e0eeff70c50b917613023d Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Tue, 11 Mar 2014 10:08:16 +0800 Subject: [PATCH] Check if value is struct before check Field --- main_test.go | 3 ++- scope.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main_test.go b/main_test.go index 6d89659a..dc60de24 100644 --- a/main_test.go +++ b/main_test.go @@ -40,7 +40,8 @@ type User struct { CreditCard CreditCard Latitude float64 PasswordHash []byte - IgnoreMe int64 `sql:"-"` + IgnoreMe int64 `sql:"-"` + IgnoreStringSlice []string `sql:"-"` } type CreditCard struct { diff --git a/scope.go b/scope.go index dba091af..78742d89 100644 --- a/scope.go +++ b/scope.go @@ -252,7 +252,7 @@ func (scope *Scope) Fields() []*Field { case reflect.Slice: typ = typ.Elem() - if _, ok := field.Value.([]byte); !ok { + if typ.Kind() == reflect.Struct { foreignKey := scopeTyp.Name() + "Id" if reflect.New(typ).Elem().FieldByName(foreignKey).IsValid() { field.ForeignKey = foreignKey