Skip to content

abnormal behavior with find operation #37

@pzmosquito

Description

@pzmosquito

Hi Marc,

Jack (my colleague) and I found something that I can't explain. In a collection, the find operation will behave differently when there's 1 and more than 1 documents. I tested it on 2 machines with CF9 and CF10, both had same abnormal result. Jack ran the same test with pure Java driver, it behaves normally.

Here's how to test it:

empty a collection and insert documents in test case 1, run test code. Do the same operation with test case 2. Both test cases should output the same result. But it did not.

test case 1:
{ "id1" : "3", "id2" : 4 }

test case 2:
{ "id1" : "3", "id2" : 4 }
{ "id1" : 10, "id2" : "11" }

test code:

writeOutput("finding 3: ");
if (coll.query().$eq("id1", 3).find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/>");

writeOutput('finding "3": ');
if (coll.query().$eq("id1", "3").find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/>");

writeOutput('finding javaCast("int", 3): ');
if (coll.query().$eq("id1", javaCast("int", 3)).find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/>");

writeOutput('finding javaCast("string", "3"): ');
if (coll.query().$eq("id1", javaCast("string", "3")).find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/><hr/>");

writeOutput("finding 4: ");
if (coll.query().$eq("id2", 4).find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/>");

writeOutput('finding "4": ');
if (coll.query().$eq("id2", "4").find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/>");

writeOutput('finding javaCast("int", 4): ');
if (coll.query().$eq("id2", javaCast("int", 4)).find().asCursor().size() == 1) writeOutput("found");
writeOutput("<br/>");

writeOutput('finding javaCast("string", "4"): ');
if (coll.query().$eq("id2", javaCast("string", "4")).find().asCursor().size() == 1) writeOutput("found");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions