support embedded structs if they support the sql.Scanner interface

This commit is contained in:
deoxxa 2015-01-22 18:15:09 +11:00
parent 5330572c25
commit f2f4ef81ca

View File

@ -2,6 +2,7 @@ package gorm
import ( import (
"fmt" "fmt"
"reflect"
"strings" "strings"
) )
@ -30,7 +31,11 @@ func Create(scope *Scope) {
continue continue
} }
columns = append(columns, scope.Quote(field.DBName)) columns = append(columns, scope.Quote(field.DBName))
sqls = append(sqls, scope.AddToVars(field.Field.Interface())) val := field.Field
if val.Kind() == reflect.Struct {
val = val.Addr()
}
sqls = append(sqls, scope.AddToVars(val.Interface()))
} }
} }