Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abnormal behavior with find operation #37

Open
pzmosquito opened this issue Mar 19, 2013 · 1 comment
Open

abnormal behavior with find operation #37

pzmosquito opened this issue Mar 19, 2013 · 1 comment

Comments

@pzmosquito
Copy link

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");

@marcesher
Copy link
Owner

It'd be extremely helpful to have this written as a standalone MXUnit test, with proper setUp() to create the conditions (and tearDown()) to blow away the data.

The assertions for your conditions above should clearly illustrate what is expected.

This way, I can simply run the test, see what assertions fail, and help you figure out what's going on.

Also, all the javascasts to int and string are useless... cfmongodb is going to turn all those ints into numbers anyways... at least, it should be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants