// Limit will create a query and add a limit clause to it.
//
// 	c.Limit(10)
350512
func (c *Connection) Limit(limit int) *Query {
	return Q(c).Limit(limit)
}
1352130
func (bldr *aeBackupInformationKindFilesQueryBuilder) Limit(limit int) *aeBackupInformationKindFilesQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}
788660
func (s *SortCommand) Limit(offset, count int) *SortCommand {
	s.limit = true
	s.offset = offset
	s.count = count
	return s
}
1261038
func (f *FilterOp) Limit(maxResults int) *FilterOp {
	f.LimitProp = &LimitFilter{Value: maxResults}
	return f
}
888759
func (c *BotTasksCall) Limit(limit int64) *BotTasksCall {
	c.urlParams_.Set("limit", fmt.Sprint(limit))
	return c
}
776485
func (me *DefaultAdapter) LimitSql(buf *SqlBuilder, limit interface{}) error {
	if limit != nil {
		buf.Write(me.LimitFragment)
		return me.Literal(buf, limit)
	}
	return nil
}
825371
func Limit(limit int) func(*index.Options) {
	return func(opts *index.Options) {
		opts.Limit = limit
	}
}
1340008
func (_m *DBClient) IntervalsWithLimit(limit int) ([]models.Interval, error) {
	ret := _m.Called(limit)

	var r0 []models.Interval
	if rf, ok := ret.Get(0).(func(int) []models.Interval); ok {
		r0 = rf(limit)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]models.Interval)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(int) error); ok {
		r1 = rf(limit)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1057862
func (q *BaseQueryBuilder) BuildOrderByAndLimit(sql string, cols []string, limit int64, offset int64) string {
	if orderBy := q.BuildOrderBy(cols); orderBy != "" {
		sql += " " + orderBy
	}
	if limit := q.BuildLimit(limit, offset); limit != "" {
		return sql + " " + limit
	}
	return sql
}
542889
func limit(limit int) scope {
	return scopeFunc(func(db *gorm.DB) *gorm.DB {
		return db.Limit(limit)
	})
}
298554
func (c *ChannelsListCall) Limit(limit int) *ChannelsListCall {
	c.limit = limit
	return c
}
110136
func (bldr *aeBackupInformationKindTypeInfoQueryBuilder) Limit(limit int) *aeBackupInformationKindTypeInfoQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}
1355352
func (p *queryPlan) limit() {
	if p.stm.IsLimitSet() {
		tracer.Trace(p.tracer, func() []string {
			return []string{"Limit results to " + strconv.Itoa(int(p.stm.Limit()))}
		})
		p.tbl.Limit(p.stm.Limit())
	}
}
1292590
func (bldr *iisQueryBuilder) Limit(limit int) *iisQueryBuilder {
	bldr.q = bldr.q.Limit(limit)
	if bldr.plugin != nil {
		bldr.plugin.Limit(limit)
	}
	return bldr
}
7865
func (b *Builder) Limit(limitN int, offset ...int) *Builder {
	b.limitation = &limit{limitN: limitN}

	if len(offset) > 0 {
		b.limitation.offset = offset[0]
	}

	return b
}
1247618
func (q *BaseQueryBuilder) BuildLimit(limit int64, offset int64) string {
	if limit < 0 && offset > 0 {
		// most DBMS requires LIMIT when OFFSET is present
		limit = 9223372036854775807 // 2^63 - 1
	}

	sql := ""
	if limit >= 0 {
		sql = fmt.Sprintf("LIMIT %v", limit)
	}
	if offset <= 0 {
		return sql
	}
	if sql != "" {
		sql += " "
	}
	return sql + fmt.Sprintf("OFFSET %v", offset)
}
1102577
func (self *Query) extendQuery(mgoQuery *mgo.Query) {

	if self.selector != nil {
		mgoQuery.Select(self.selector)
	}

	if len(self.sort) > 0 {
		mgoQuery.Sort(self.sort...)
	}

	if self.limit != 0 {
		mgoQuery.Limit(self.limit)
	}

	if self.skip != 0 {
		mgoQuery.Skip(self.skip)
	}
}