Before this PR, the iterator `is_ok` status relied on `mongoc_cursor_more` that can return
true even if the iterator is terminated.
This PR fixes the problem by using the result of `mongoc_cursor_next` instead.
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>
var c = native.find(query.to_bson.native)
if c == null then return res
var cursor = new MongoCursor(c)
- for item in cursor do res.add item
+ while cursor.is_ok do
+ res.add cursor.item
+ cursor.next
+ end
return res
end
init do next
- redef fun is_ok do return native.more
+ redef var is_ok = true
- redef fun next do native.next
+ redef fun next do is_ok = native.next
redef fun item do
return new JsonObject.from_bson(new BSON(native.current))
return mongoc_cursor_next(self, &doc);
`}
- # Wrapper for `mongoc_cursor_more()`.
- #
- # This function shall indicate if there is more data to be read from the cursor.
- fun more: Bool `{ return mongoc_cursor_more(self); `}
-
# Wrapper for `mongoc_cursor_destroy()`.
#
# This instance should not be used beyond this point!