mirror of https://github.com/go-gorm/gorm.git
Fixed detecting pointers as a Scanner. thanks @NOX73
This commit is contained in:
parent
7fcb3e889f
commit
1d4f908ea2
|
@ -49,7 +49,7 @@ func init() {
|
||||||
|
|
||||||
// DB.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
|
// DB.SetLogger(Logger{log.New(os.Stdout, "\r\n", 0)})
|
||||||
// DB.SetLogger(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)
|
DB.LogMode(false)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -156,12 +156,12 @@ func (scope *Scope) GetModelStruct() *ModelStruct {
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
if !field.IsIgnored {
|
if !field.IsIgnored {
|
||||||
fieldStruct := field.Struct
|
fieldStruct := field.Struct
|
||||||
fieldType, indirectType := fieldStruct.Type, fieldStruct.Type
|
indirectType := fieldStruct.Type
|
||||||
if indirectType.Kind() == reflect.Ptr {
|
if indirectType.Kind() == reflect.Ptr {
|
||||||
indirectType = indirectType.Elem()
|
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
|
field.IsScanner, field.IsNormal = true, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -581,7 +581,6 @@ func TestSelectWithArrayInput(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCurrentDatabase(t *testing.T) {
|
func TestCurrentDatabase(t *testing.T) {
|
||||||
DB.LogMode(true)
|
|
||||||
databaseName := DB.CurrentDatabase()
|
databaseName := DB.CurrentDatabase()
|
||||||
if err := DB.Error; err != nil {
|
if err := DB.Error; err != nil {
|
||||||
t.Errorf("Problem getting current db name: %s", err)
|
t.Errorf("Problem getting current db name: %s", err)
|
||||||
|
|
Loading…
Reference in New Issue