fix group by duplicate column on mysql

This commit is contained in:
lirui 2024-10-23 15:18:11 +08:00
parent d47f35b260
commit 88182564a9
1 changed files with 6 additions and 1 deletions

View File

@ -161,7 +161,12 @@ func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interfa
var subQuerySelect string var subQuerySelect string
if statement.GroupByStr != "" { if statement.GroupByStr != "" {
i := strings.Index(statement.GroupByStr, ",")
if i > -1 {
subQuerySelect = statement.GroupByStr[:i]
} else {
subQuerySelect = statement.GroupByStr subQuerySelect = statement.GroupByStr
}
} else { } else {
subQuerySelect = selectSQL subQuerySelect = selectSQL
} }