Issue #12 resolved

Limit not working

kisyad
created an issue

Hi,

Currently only {limit, 1} seems to be working.

Test case

{{{ emongo:insert(pool1, "testlimit", {id, 1}). emongo:insert(pool1, "testlimit", {id, 2}). emongo:insert(pool1, "testlimit", {id, 3}). length(emongo:find_all(pool1, "testlimit", [], [ {limit, 2} ] )).
}}}

-> result 3

I did a quick look and everything seems to go fine up to emongo:fold_all_seq.

NewValue = fold_documents(F, Value, Resp), seems to return two documents as expected but then fold_more is called which ignores the limit and returns all 3 documents.

Comments (2)

  1. Dmitry Belyaev repo owner
    • changed status to open

    The problem is that on first call of query mongodb returns required set of documents in one response (e.g. 1000 documents in one response) and leaves cursor alive and ready for further fetching beyond desired limit. And fold_more assumes that mongodb will tell when the query is over with cursor value of 0.

  2. Log in to comment