Skip to content

Commit

Permalink
🐛 fix: search current page delete (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwnmengjing authored Aug 19, 2024
1 parent ff0cee0 commit e766200
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/response/actions/gorm/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ func (e *Search) search(c *gin.Context) {
scopes = append(scopes, e.opts.Scope(c, m))
}
query := db.Model(m).Scopes(scopes...)
//if err := query.Limit(-1).Offset(-1).Count(&count).Error; err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
// api.AddError(err).Log.ErrorContext(c, "Search error", "error", err)
// api.Err(http.StatusInternalServerError)
// return
//}

if e.opts.TreeField != "" && e.opts.Depth > 0 {
treeFields := make([]string, 0, e.opts.Depth)
Expand Down Expand Up @@ -122,7 +117,9 @@ func (e *Search) search(c *gin.Context) {
}
items = append(items, m)
}
err = query.Limit(-1).Offset(-1).Count(&count).Error
err = query.Scopes(func(db *gorm.DB) *gorm.DB {
return db.Limit(-1).Offset(-1)
}).Count(&count).Error
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
api.AddError(err).Log.ErrorContext(c, "search error", "error", err)
api.Err(http.StatusInternalServerError)
Expand Down

0 comments on commit e766200

Please sign in to comment.