Fixed detecting pointers as a Scanner. thanks @NOX73

This commit is contained in:
Jinzhu 2015-08-12 22:28:01 +08:00
parent 905b6232a3
commit 197ae0e893
2 changed files with 2 additions and 3 deletions

View File

@ -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
}

View File

@ -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)