Lytol / Mongo.jl

Mongo bindings for the Julia programming language
MIT License
30 stars 37 forks source link

Cursor reset looses query information #22

Open rened opened 10 years ago

rened commented 10 years ago

Perhaps this is by design, but I would have expected a cursor, when it is reset, to always perform identically. The following shows that the cursor reset code in reset(cursor::MongoCursor) seems to remove the query information?

using Mongo
client = MongoClient();
db = "test.people"
insert(client, db, { "name" => "A", "age" => 20})
insert(client, db, { "name" => "B", "age" => 20})
insert(client, db, { "name" => "C", "age" => 30})
cursor = find(client, "test.people", { "age" => 20 })

# this will display A and B
for doc in cursor
  @show doc
end

# this will display _all_ entries, A,B,C
for doc in cursor
  @show doc
end
Lytol commented 10 years ago

The cursor should definitely retain the query and fields, so this is a bug. I'll take a look as soon as I get a chance.