mirror of https://github.com/go-gorm/gorm.git
Puts errors for ptr values
This commit is contained in:
parent
b9f4a59772
commit
2d40175651
11
model.go
11
model.go
|
@ -130,7 +130,14 @@ func (m *Model) fields(operation string) (fields []Field) {
|
|||
if field.IsPrimaryKey {
|
||||
field.SqlType = getPrimaryKeySqlType(m.driver, field.Value, 0)
|
||||
} else {
|
||||
switch reflect.TypeOf(field.Value).Kind() {
|
||||
field_value := reflect.ValueOf(field.Value)
|
||||
if field_value.Kind() == reflect.Ptr {
|
||||
if field_value.CanAddr() {
|
||||
field_value = field_value.Elem()
|
||||
}
|
||||
}
|
||||
|
||||
switch field_value.Kind() {
|
||||
case reflect.Slice:
|
||||
field.afterAssociation = true
|
||||
case reflect.Struct:
|
||||
|
@ -143,6 +150,8 @@ func (m *Model) fields(operation string) (fields []Field) {
|
|||
field.afterAssociation = true
|
||||
}
|
||||
}
|
||||
case reflect.Ptr:
|
||||
debug("Errors when handle ptr sub structs")
|
||||
default:
|
||||
field.SqlType = getSqlType(m.driver, field.Value, 0)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue