diff --git a/clause/limit.go b/clause/limit.go index 3ede7385c..abda00551 100644 --- a/clause/limit.go +++ b/clause/limit.go @@ -33,7 +33,7 @@ func (limit Limit) MergeClause(clause *Clause) { clause.Name = "" if v, ok := clause.Expression.(Limit); ok { - if (limit.Limit == nil || *limit.Limit == 0) && (v.Limit != nil && *v.Limit != 0) { + if (limit.Limit == nil || *limit.Limit == 0) && v.Limit != nil { limit.Limit = v.Limit } diff --git a/clause/limit_test.go b/clause/limit_test.go index 79065ab67..a9fd4e24a 100644 --- a/clause/limit_test.go +++ b/clause/limit_test.go @@ -28,6 +28,10 @@ func TestLimit(t *testing.T) { []clause.Interface{clause.Select{}, clause.From{}, clause.Limit{Limit: &limit0}}, "SELECT * FROM `users` LIMIT 0", nil, }, + { + []clause.Interface{clause.Select{}, clause.From{}, clause.Limit{Limit: &limit0}, clause.Limit{Offset: 0}}, + "SELECT * FROM `users` LIMIT 0", nil, + }, { []clause.Interface{clause.Select{}, clause.From{}, clause.Limit{Offset: 20}}, "SELECT * FROM `users` OFFSET 20", nil,