Fixed improper limit check for aggregate and join
This commit is contained in:
@@ -87,7 +87,7 @@ func (xs *aggregate) Next(ctx context.Context) (more bool) {
|
||||
func (xs *aggregate) next(ctx context.Context) (more bool, err error) {
|
||||
var g *aggregateGroup
|
||||
for {
|
||||
if xs.ctr >= int(xs.filter.limit) {
|
||||
if xs.limitExceeded() {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -134,6 +134,10 @@ func (xs *aggregate) next(ctx context.Context) (more bool, err error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (xs *aggregate) limitExceeded() bool {
|
||||
return xs.filter.limit > 0 && xs.ctr >= int(xs.filter.limit)
|
||||
}
|
||||
|
||||
func (xs *aggregate) More(limit uint, v ValueGetter) (err error) {
|
||||
// Redo the cursor
|
||||
xs.filter.cursor, err = filter.PagingCursorFrom(xs.filter.OrderBy(), v, xs.collectPrimaryAttributes()...)
|
||||
|
||||
@@ -162,7 +162,7 @@ func (xs *joinLeft) ForwardCursor(v ValueGetter) (pc *filter.PagingCursor, err e
|
||||
|
||||
// next prepares the next scan row based on the defined join plan
|
||||
func (xs *joinLeft) next(ctx context.Context) (more bool, err error) {
|
||||
if xs.i >= int(xs.filter.limit) {
|
||||
if !xs.limitExceeded() {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -176,6 +176,10 @@ func (xs *joinLeft) next(ctx context.Context) (more bool, err error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (xs *joinLeft) limitExceeded() bool {
|
||||
return xs.filter.limit > 0 && xs.i >= int(xs.filter.limit)
|
||||
}
|
||||
|
||||
// pullNext pulls additional data so we can produce more
|
||||
//
|
||||
// This step may be omitted based on the join plan.
|
||||
|
||||
Reference in New Issue
Block a user