diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 64a49a003..43f4c3d5e 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -218,8 +218,12 @@ func (sqls *SQLStorage) GetCDRs(ctx *context.Context, qryFltr []*Filter, opts ma if maxItems < limit+offset { return nil, fmt.Errorf("sum of limit and offset exceeds maxItems") } - q = q.Limit(limit) - q = q.Offset(offset) + if limit > 0 { + q = q.Limit(limit) + } + if offset > 0 { + q = q.Offset(offset) + } // Execute query results := make([]*utils.CDRSQLTable, 0)