Skip to content

Commit

Permalink
♻️ Refator(paginate.go): update count query to use id column paginate…
Browse files Browse the repository at this point in the history
… tag name
  • Loading branch information
booscaaa committed Nov 13, 2023
1 parent bb578e6 commit 5dcac5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions v2/paginate/paginate.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ func GenerateCountQuery(params *paginQueryParams) (string, []interface{}) {

// Cláusula SELECT para contagem
countSelectClause := "SELECT COUNT(id)"
idColumnName := getFieldName("id", "json", "paginate", params.Struct)

if idColumnName != "" {
countSelectClause = fmt.Sprintf("SELECT %s", idColumnName)
}

clauses = append(clauses, countSelectClause)

// Cláusula FROM com tabela principal
Expand Down

0 comments on commit 5dcac5f

Please sign in to comment.