Skip to content

Commit 0234067

Browse files
committed
minor group by fix
1 parent a06f3b7 commit 0234067

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

gateway/modules/crud/sql/read.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (s *SQL) generateReadQuery(ctx context.Context, col string, req *model.Read
124124
query = query.Select(selArray...)
125125
if len(req.GroupBy) > 0 {
126126
for _, group := range req.GroupBy {
127-
if strings.Split(group.(string), ".")[0] != col && req.Options.ReturnType != "table" {
127+
if arr := strings.Split(group.(string), "."); len(arr) > 1 && arr[0] != col && req.Options.ReturnType != "table" {
128128
return "", nil, fmt.Errorf("use `returnType` `table` to perform group by on joint tables")
129129
}
130130
}

0 commit comments

Comments
 (0)