Fix Count methods

This commit is contained in:
Deluan
2021-07-16 20:20:33 -04:00
committed by Deluan Quintão
parent 20b7e5c49b
commit a0cd585401
5 changed files with 22 additions and 30 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ func (r sqlRepository) exists(existsQuery SelectBuilder) (bool, error) {
}
func (r sqlRepository) count(countQuery SelectBuilder, options ...model.QueryOptions) (int64, error) {
countQuery = countQuery.Columns("count(*) as count").From(r.tableName)
countQuery = countQuery.Columns("count(distinct " + r.tableName + ".id) as count").From(r.tableName)
countQuery = r.applyFilters(countQuery, options...)
var res struct{ Count int64 }
err := r.queryOne(countQuery, &res)