forked from mirror/gorm
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 {
|
if field.IsPrimaryKey {
|
||||||
field.SqlType = getPrimaryKeySqlType(m.driver, field.Value, 0)
|
field.SqlType = getPrimaryKeySqlType(m.driver, field.Value, 0)
|
||||||
} else {
|
} 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:
|
case reflect.Slice:
|
||||||
field.afterAssociation = true
|
field.afterAssociation = true
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
|
@ -143,6 +150,8 @@ func (m *Model) fields(operation string) (fields []Field) {
|
||||||
field.afterAssociation = true
|
field.afterAssociation = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case reflect.Ptr:
|
||||||
|
debug("Errors when handle ptr sub structs")
|
||||||
default:
|
default:
|
||||||
field.SqlType = getSqlType(m.driver, field.Value, 0)
|
field.SqlType = getSqlType(m.driver, field.Value, 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue