Fix change limit.Limit type

This commit is contained in:
Jinzhu
2022-10-07 19:34:35 +08:00
parent fd61679859
commit ea59bcf5bc
3 changed files with 9 additions and 9 deletions

View File

@@ -97,13 +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 != nil && *limit.Limit >= 0) || limit.Offset > 0 {
if *limit.Limit <= 0 {
i := -1
limit.Limit = &i
}
var lmt = -1
if limit.Limit != nil && *limit.Limit >= 0 {
lmt = *limit.Limit
}
if lmt > 0 || limit.Offset > 0 {
builder.WriteString("LIMIT ")
builder.WriteString(strconv.Itoa(*limit.Limit))
builder.WriteString(strconv.Itoa(lmt))
}
if limit.Offset > 0 {
builder.WriteString(" OFFSET ")