Only group by if using having clauses (#1750)

* Only group by if using having clauses
* Change tag sorting SQL
* Add sorting unit tests
This commit is contained in:
WithoutPants
2021-10-01 16:24:58 +10:00
committed by GitHub
parent e3480531a7
commit ca0a8b00ec
4 changed files with 42 additions and 11 deletions

View File

@@ -238,8 +238,8 @@ func (r *repository) buildQueryBody(body string, whereClauses []string, havingCl
if len(whereClauses) > 0 {
body = body + " WHERE " + strings.Join(whereClauses, " AND ") // TODO handle AND or OR
}
body = body + " GROUP BY " + r.tableName + ".id "
if len(havingClauses) > 0 {
body = body + " GROUP BY " + r.tableName + ".id "
body = body + " HAVING " + strings.Join(havingClauses, " AND ") // TODO handle AND or OR
}