[JAVA-527] $all does not work correctly Created: 29/Feb/12  Updated: 29/Feb/12  Resolved: 29/Feb/12

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

Type: Bug Priority: Major - P3
Reporter: Robert Widmer Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File sample query.txt    

 Description   

There are no results returned when using $all in a query even though running the same query in a client will return results. If I change it to use $in it will return results. Here is an example of a query that works:

{
"PPL.ID" :

{ "$in" : [63,942] }

,
"DUO" : true
}

Here is the one that doesn't:
{
"PPL.ID" :

{ "$all" : [63,942] }

,
"DUO" : true
}

PPL is an array of objects:
{
"ID" : integer,
"NAME" : string
}

I realize they are two different queries, but when I run the second query through another client it does return results. I included the version using "$in" to demonstrate that the query as set up in Java isn't broken. I am currently running against MongoDB version 1.6.3 on Windows.



 Comments   
Comment by Robert Widmer [ 29/Feb/12 ]

Alright, thank you for looking in to it. It must just be something with how coldfusion interfaces with the driver.

Comment by Jeffrey Yemin [ 29/Feb/12 ]

Here's a Java program that demonstrates that it works properly using the Java driver (I tested with 2.7.3):

 
public class JAVA527Test {
    public static void main(String[] args) throws UnknownHostException {
        Mongo m = new Mongo("127.0.0.1");
        DB db = m.getDB("JAVA527");
        DBCollection col = db.getCollection("test");
        DBObject query = new BasicDBObject();
        query.put("DUO", true);
        query.put("PPL.ID", new BasicDBObject("$all", new int[] {63, 942}));
        DBObject obj = col.findOne(query);
        System.out.println(obj);
    }
}

which prints out

{ "_id" : { "$oid" : "4f4e3f71a79301c9e75a8ac2"} , "CID" : { "$oid" : "4f4e3f71a79301c9e75a8ac2"} , "MSG" : "Hello" , "PPL" : [ { "ID" : 63.0 , "RD" : "Wed Feb 29 2012 10:08:33 GMT-0500 (Eastern Standard Time)" , "SND" : true , "NM" : "Teacher"} , { "ID" : 942.0 , "NM" : "Hayden"}] , "DUO" : true}

Comment by Robert Widmer [ 29/Feb/12 ]

Hi Scott,
Here is the shell output. I unfortunately can't provide you with a java file because we are using the driver through coldfusion. So I only have the coldfusion code. All I have to go on is that by changing the string "$all" to "$in" in my code it returns results. That's what leads me to believe that it is the Java driver that is having the issue. I also realized I misstated the version of Mongo we are using. It is actually 1.6.5.

Comment by Scott Hernandez (Inactive) [ 29/Feb/12 ]

Can you include a java class which inserts the test data, and does the queries which don't work?

Also, a mongo javascript shell session would help showing it working.

Generated at Thu Feb 08 08:52:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.