[CDRIVER-97] Advanced query fails Created: 15/Sep/11  Updated: 03/May/17  Resolved: 15/Sep/11

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Horen Assignee: Kyle Banker
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS 10.7



 Description   

Advanced query like find( { dst : "ABCD" , obsTime : { $gt : 1310612524, $lt : 1310613524}}).sort(

{obsTime :1 }

) fails

$gt and $lt works fine, adding $query returns the entire data set, adding sort returns 0 documents.



 Comments   
Comment by Kyle Banker [ 15/Sep/11 ]

Awesome. Glad it worked!

Comment by Horen [ 15/Sep/11 ]

Kyle,
Excellent and fast response. It now works.

Thank you very much.

-Horen

Comment by Horen [ 15/Sep/11 ]

Kyle,
Excellent and fast response. It now works.

Thank you very much.

Comment by Kyle Banker [ 15/Sep/11 ]

You need to wrap the entire query in $query and the entire sort clause in $orderby.

Please try this:

bson_init(&b);
bson_append_start_object(&b,"$query");
bson_append_string(&b,"airport","KATL");
bson_append_start_object(&b,"obsTime");
bson_append_int(&b,"$gt",1310712524);
bson_append_int(&b,"$lt",1310723000);
bson_append_finish_object(&b);
bson_append_finish_object(&b);
bson_append_start_object(&b, "$orderby")
bson_append_int(&b, "obsTime", 1);
bson_append_finish_object(&b);
bson_finish(&b);

Comment by Horen [ 15/Sep/11 ]

bson_init(&b);
bson_append_start_object(&b,"obsTime");
bson_append_int(&b,"$gt",1310712524);
bson_append_int(&b,"$lt",1310723000);
bson_append_finish_object(&b);
bson_finish(&b);

works fine.

bson_init(&b);
bson_append_start_object(&b,"$query");
bson_append_string(&b,"airport","KATL");
bson_append_finish_object(&b);
bson_append_start_object(&b,"obsTime");
bson_append_int(&b,"$gt",1310712524);
bson_append_int(&b,"$lt",1310723000);
bson_append_finish_object(&b);
bson_finish(&b);

returns the entire data set.

Comment by Kyle Banker [ 15/Sep/11 ]

Can provide a failing test case with code, please?

Generated at Wed Feb 07 21:08:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.