orm: inline struct support
This commit is contained in:
@@ -140,7 +140,7 @@ func (o *orm) ReadOrCreate(md interface{}, col1 string, cols ...string) (bool, i
|
||||
return (err == nil), id, err
|
||||
}
|
||||
|
||||
return false, ind.Field(mi.fields.pk.fieldIndex).Int(), err
|
||||
return false, ind.FieldByIndex(mi.fields.pk.fieldIndex).Int(), err
|
||||
}
|
||||
|
||||
// insert model data to database
|
||||
@@ -160,9 +160,9 @@ func (o *orm) Insert(md interface{}) (int64, error) {
|
||||
func (o *orm) setPk(mi *modelInfo, ind reflect.Value, id int64) {
|
||||
if mi.fields.pk.auto {
|
||||
if mi.fields.pk.fieldType&IsPostiveIntegerField > 0 {
|
||||
ind.Field(mi.fields.pk.fieldIndex).SetUint(uint64(id))
|
||||
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetUint(uint64(id))
|
||||
} else {
|
||||
ind.Field(mi.fields.pk.fieldIndex).SetInt(id)
|
||||
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetInt(id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -290,7 +290,7 @@ func (o *orm) LoadRelated(md interface{}, name string, args ...interface{}) (int
|
||||
qs.orders = []string{order}
|
||||
}
|
||||
|
||||
find := ind.Field(fi.fieldIndex)
|
||||
find := ind.FieldByIndex(fi.fieldIndex)
|
||||
|
||||
var nums int64
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user