Fixing page limit on cosmosdb
@@ -147,9 +147,10 @@ func (q *Query) setNextParameter(val string) string {
func (q *Query) execute(client *azcosmos.ContainerClient) ([]state.QueryItem, string, error) {
opts := &azcosmos.QueryOptions{}
+ resultLimit := q.limit
opts.QueryParameters = append(opts.QueryParameters, q.query.parameters...)
if q.limit != 0 {
- opts.PageSizeHint = int32(q.limit)
+ opts.PageSizeHint = int32(resultLimit)
}
if len(q.token) != 0 {
opts.ContinuationToken = q.token
@@ -175,8 +176,14 @@ func (q *Query) execute(client *azcosmos.ContainerClient) ([]state.QueryItem, st
if err != nil {
return nil, "", err
}
+ if (len(items) + 1) > resultLimit {
+ break
+ }
items = append(items, tempItem)
}
+ if (len(items) + 1) > resultLimit {
+ break
+ }
}
ret := make([]state.QueryItem, len(items))
