Skip to content

Commit

Permalink
mysql only accept offset with limit together
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jul 3, 2017
1 parent d395b35 commit d510c7e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dialect_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ func (s mysql) LimitAndOffsetSQL(limit, offset interface{}) (sql string) {
if limit != nil {
if parsedLimit, err := strconv.ParseInt(fmt.Sprint(limit), 0, 0); err == nil && parsedLimit >= 0 {
sql += fmt.Sprintf(" LIMIT %d", parsedLimit)
}

if offset != nil {
if parsedOffset, err := strconv.ParseInt(fmt.Sprint(offset), 0, 0); err == nil && parsedOffset >= 0 {
sql += fmt.Sprintf(" OFFSET %d", parsedOffset)
if offset != nil {
if parsedOffset, err := strconv.ParseInt(fmt.Sprint(offset), 0, 0); err == nil && parsedOffset >= 0 {
sql += fmt.Sprintf(" OFFSET %d", parsedOffset)
}
}
}
}
Expand Down

0 comments on commit d510c7e

Please sign in to comment.