Skip to content

Commit

Permalink
Let MongoCursor.limit only decrease the limit, never increase.
Browse files Browse the repository at this point in the history
See also #499.
  • Loading branch information
s-ludwig committed Feb 6, 2014
1 parent 26fd18f commit 824a752
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions source/vibe/db/mongo/cursor.d
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,13 @@ struct MongoCursor {
/**
Limits the maximum documents that cursor returns.
This method must be called before beginnig iteration in order to have effect.
Only last limit() applied to cursor has any effect.
This method must be called before beginnig iteration in order to have
effect. If multiple calls to limit() are made, the one with the lowest
limit will be chosen.
Params:
count = a number of documents
count = The maximum number number of documents to return. A value
of zero means unlimited.
Returns: the same cursor
Expand Down Expand Up @@ -224,9 +226,10 @@ private class MongoCursorData {
if (count > 0) {
if (m_nret == 0 || m_nret > count)
m_nret = min(count, 1024);
}

m_limit = count;
if (m_limit == 0 || m_limit > count)
m_limit = count;
}
}

void popFront()
Expand Down

0 comments on commit 824a752

Please sign in to comment.