Open pzmosquito opened 11 years ago
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
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");