Skip to content

Commit

Permalink
♻️ Refactor(paginate.go): add replace count
Browse files Browse the repository at this point in the history
  • Loading branch information
booscaaa committed Nov 9, 2023
1 parent 4c099b1 commit d1cb25b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions v2/paginate/paginate.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func GenerateCountQuery(params *paginQueryParams) (string, []interface{}) {
}

// Cláusula SELECT para contagem
countSelectClause := "SELECT COUNT(*)"
countSelectClause := "SELECT COUNT(id)"
clauses = append(clauses, countSelectClause)

// Cláusula FROM com tabela principal
Expand Down Expand Up @@ -317,7 +317,8 @@ func GenerateCountQuery(params *paginQueryParams) (string, []interface{}) {
// Verifica se VACUUM deve ser aplicado
if params.Vacuum {
countQuery := strings.Join(clauses, " ")
countQuery = "SELECT count_estimate(" + countQuery + ");"
countQuery = "SELECT count_estimate('" + countQuery + "');"
countQuery = strings.Replace(countQuery, "COUNT(id)", "1", -1)
return countQuery, args
}

Expand Down

0 comments on commit d1cb25b

Please sign in to comment.