marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

Issues with MongoDB 2.6 and CFMongoDB #46

Open appdevjrcigars opened 10 years ago

appdevjrcigars commented 10 years ago

It appears the find method is no longer returning records that match the criteria specified using MongoDB 2.6.x (did not work with 2.6.1 or 2.6.3)). A find is returning 0 results, regardless of the criteria, unless I put a limit. Limit is functioning, but it ignores any search criteria specified. The asArray() method is extremely slow and mostly returns error 500. Is anyone else seeing these problems?

marcesher commented 10 years ago

@appdevjrcigars I haven't tried CFMongoDB with mongo 2.6 yet (I rarely work in CF anymore, alas).

If you turn on profiling (db.setProfilingLevel(2)) to log all queries, do you see anything strange in there that would indicate why find() isn't returning results?

appdevjrcigars commented 10 years ago

Thanks for your prompt reply. Turning on profiling helped indeed to see why 0 results are being returned since it revealed that, no matter how hard I try, if I query on a string field (e.g. trandate) that contains a string with only numeric values (e.g. "20140702"), the translation of the query from CFMongoDB to mongodb is an integer value instead of string. So for example, the query db.find({'trandate':'20140702'}).asArray() is interpreted as db.find({'trandate':20140702}).asArray(). I have tried double quotes, single quotes, quotes with extra quotes, converting the value toString(), etc., but to no avail. If I try a different CFMongoDB syntax (e.g. db.find(query={'trandate'='20140702'},sort={'trandate'=1}).asArray(), that's when I receive error 500s and 502s from the server, and I have to restart the CF Service to continue. I also tried the syntax db.query().$eq('trandate','20140702').find().asArray() and no luck. Unfortunately, I'm unable to determine why the CF Server crashes, but I'm assuming it is unable to parse the query correctly. BTW, I'm using CF10 with MongoDB 2.6.3.

appdevjrcigars commented 10 years ago

Thanks again...I just found a workaround right there in the examples:

mongoUtil = mongo.getMongoUtil(); get_allTransactionMetricsArray = db.find({'trandate': mongoUtil.asString("20140702")}).asArray();

The code above works perfectly. Thanks for your help.

marcesher commented 10 years ago

Great. Glad you got it working.

On Thursday, July 3, 2014, appdevjrcigars notifications@github.com wrote:

Thanks again...I just found a workaround right there in the examples:

mongoUtil = mongo.getMongoUtil(); get_allTransactionMetricsArray = db.find({'trandate': mongoUtil.asString("20140702")}).asArray();

The code above works perfectly. Thanks for your help.

— Reply to this email directly or view it on GitHub https://github.com/marcesher/cfmongodb/issues/46#issuecomment-47929817.