Skip to content

Commit

Permalink
fix the page op builder
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Jul 31, 2023
1 parent ef6ed5f commit 03fd55f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions op_pagination.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ func init() {
}

func newPageSize() OpBuilder {
return OpBuilderFunc(func(ab *ArgsBuilder, _op op.Op) string {
return OpBuilderFunc(func(ab *ArgsBuilder, _op op.Op) (sql string) {
ps := _op.Val.(op.PageSize)
return ab.Dialect.LimitOffset(ps.Size, (ps.Page-1)*ps.Size)
if ps.Page > 0 && ps.Size > 0 {
sql = ab.Dialect.LimitOffset(ps.Size, (ps.Page-1)*ps.Size)
}
return
})
}

0 comments on commit 03fd55f

Please sign in to comment.