Skip to content

Commit

Permalink
fix: limit=0 results (#5735) (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhafner committed Oct 7, 2022
1 parent 7c8ddee commit 2609fe6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ func (dialector Dialector) ClauseBuilders() map[string]clause.ClauseBuilder {
},
"LIMIT": func(c clause.Clause, builder clause.Builder) {
if limit, ok := c.Expression.(clause.Limit); ok {
if limit.Limit > 0 || limit.Offset > 0 {
if limit.Limit <= 0 {
limit.Limit = -1
if (limit.Limit != nil && *limit.Limit >= 0) || limit.Offset > 0 {
if *limit.Limit <= 0 {
i := -1
limit.Limit = &i
}
builder.WriteString("LIMIT ")
builder.WriteString(strconv.Itoa(limit.Limit))
builder.WriteString(strconv.Itoa(*limit.Limit))
}
if limit.Offset > 0 {
builder.WriteString(" OFFSET ")
Expand Down

0 comments on commit 2609fe6

Please sign in to comment.