From 1d4f908ea2d139b49ab4ce86dc6d6f3bfb259dac Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Wed, 12 Aug 2015 22:28:01 +0800 Subject: [PATCH] Fixed detecting pointers as a Scanner. thanks @NOX73 --- main_test.go | 2 +- model_struct.go | 4 ++-- query_test.go | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/main_test.go b/main_test.go index 0dc5e337..3fc30d94 100644 --- a/main_test.go +++ b/main_test.go @@ -49,7 +49,7 @@ func init() { // DB.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)}) // DB.SetLogger(log.New(os.Stdout, "\r\n", 0)) - DB.LogMode(true) + // DB.LogMode(true) DB.LogMode(false) if err != nil { diff --git a/model_struct.go b/model_struct.go index 72caec24..26c58fc5 100644 --- a/model_struct.go +++ b/model_struct.go @@ -156,12 +156,12 @@ func (scope *Scope) GetModelStruct() *ModelStruct { for _, field := range fields { if !field.IsIgnored { fieldStruct := field.Struct - fieldType, indirectType := fieldStruct.Type, fieldStruct.Type + indirectType := fieldStruct.Type if indirectType.Kind() == reflect.Ptr { indirectType = indirectType.Elem() } - if _, isScanner := reflect.New(fieldType).Interface().(sql.Scanner); isScanner { + if _, isScanner := reflect.New(indirectType).Interface().(sql.Scanner); isScanner { field.IsScanner, field.IsNormal = true, true } diff --git a/query_test.go b/query_test.go index ff022dbb..0fd58302 100644 --- a/query_test.go +++ b/query_test.go @@ -581,7 +581,6 @@ func TestSelectWithArrayInput(t *testing.T) { } func TestCurrentDatabase(t *testing.T) { - DB.LogMode(true) databaseName := DB.CurrentDatabase() if err := DB.Error; err != nil { t.Errorf("Problem getting current db name: %s", err)