This commit is contained in:
Lunny Xiao 2021-08-10 20:31:37 +08:00
parent 9fe6702252
commit 6dc2f9eec7
1 changed files with 8 additions and 2 deletions

View File

@ -110,8 +110,14 @@ func (session *Session) loadFindSlice(v reflect.Value, cols ...string) error {
}
for col, va := range pks {
slice := reflect.MakeSlice(reflect.SliceOf(col.FieldType), 0, len(va.pk))
err = session.In(va.col.Name, va.pk...).find(slice.Interface())
//slice := reflect.New(reflect.SliceOf(col.FieldType))
pkCols := col.AssociateTable.PKColumns()
if len(pkCols) != 1 {
return fmt.Errorf("unsupported primary key number")
}
mp := reflect.MakeMap(reflect.MapOf(pkCols[0].FieldType, col.FieldType))
//slice := reflect.MakeSlice(, 0, len(va.pk))
err = session.In(va.col.Name, va.pk...).find(mp.Addr().Interface())
if err != nil {
return err
}