-
Type:
Improvement
-
Resolution: Won't Fix
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Please, take a look at the following code. I think that only int -1 or 1 should be allowed here.
public static void main(String... args) throws UnknownHostException { Mongo m = new Mongo(); m.setWriteConcern(WriteConcern.SAFE); DB db = m.getDB("test"); db.dropDatabase(); DBCollection collection = db.getCollection("tmp"); //random docs insert for (int i = 0; i < 10; i++) { DBObject object = new BasicDBObject("_id", i); object.put("length", (int) (Math.random() * 100)); collection.insert(object); } print(collection.find().toArray()); //valid value BasicDBObject obj = new BasicDBObject().append("length", 1); print(collection.find().sort(obj).toArray()); //string value obj.put("length", "randomString"); print(collection.find().sort(obj).toArray()); //object value obj.put("length", new BasicDBObject()); print(collection.find().sort(obj).toArray()); } private static void print(List<DBObject> list){ System.out.println("--size "+list.size()); for(DBObject o : list){ System.out.println(o); } System.out.println("\n"); }