diff --git a/g_appcode.go b/g_appcode.go index 76d78ad..2a328b8 100644 --- a/g_appcode.go +++ b/g_appcode.go @@ -1080,7 +1080,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri } sortFields = append(sortFields, orderby) } - qs = qs.OrderBy(sortFields...) + qs = qs.OrderBy(sortFields...).RelatedSel() } else if len(sortby) != len(order) && len(order) == 1 { // 2) there is exactly one order, all the sorted fields will be sorted by this order for _, v := range sortby { @@ -1104,7 +1104,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri } var l []{{modelName}} - qs = qs.OrderBy(sortFields...) + qs = qs.OrderBy(sortFields...).RelatedSel() if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil { if len(fields) == 0 { for _, v := range l { diff --git a/g_hproseappcode.go b/g_hproseappcode.go index 2d95aec..3ce270b 100644 --- a/g_hproseappcode.go +++ b/g_hproseappcode.go @@ -238,7 +238,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri } sortFields = append(sortFields, orderby) } - qs = qs.OrderBy(sortFields...) + qs = qs.OrderBy(sortFields...).RelatedSel() } else if len(sortby) != len(order) && len(order) == 1 { // 2) there is exactly one order, all the sorted fields will be sorted by this order for _, v := range sortby { @@ -262,7 +262,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri } var l []{{modelName}} - qs = qs.OrderBy(sortFields...) + qs = qs.OrderBy(sortFields...).RelatedSel() if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil { if len(fields) == 0 { for _, v := range l { diff --git a/g_model.go b/g_model.go index ae23731..0ab9475 100644 --- a/g_model.go +++ b/g_model.go @@ -200,7 +200,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri } sortFields = append(sortFields, orderby) } - qs = qs.OrderBy(sortFields...) + qs = qs.OrderBy(sortFields...).RelatedSel() } else if len(sortby) != len(order) && len(order) == 1 { // 2) there is exactly one order, all the sorted fields will be sorted by this order for _, v := range sortby { @@ -224,7 +224,7 @@ func GetAll{{modelName}}(query map[string]string, fields []string, sortby []stri } var l []{{modelName}} - qs = qs.OrderBy(sortFields...) + qs = qs.OrderBy(sortFields...).RelatedSel() if _, err = qs.Limit(limit, offset).All(&l, fields...); err == nil { if len(fields) == 0 { for _, v := range l {