Skip to content

Commit

Permalink
ensure non-null query
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Briskin committed Jun 25, 2012
1 parent 256dd3f commit 19b5eca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/com/mongodb/QueryOpBuilder.java
Expand Up @@ -99,10 +99,17 @@ public QueryOpBuilder addSnapshot(boolean snapshot){
* @return DBObject representing the query command to be sent to server
*/
public DBObject get(){
DBObject lclQuery = query;

//must always have a query
if(lclQuery == null){
lclQuery = new BasicDBObject();
}

if(hasSpecialQueryFields()){
DBObject queryop = (specialFields == null ? new BasicDBObject() : specialFields);

addToQueryObject(queryop, "query", query, true);
addToQueryObject(queryop, "query", lclQuery, true);
addToQueryObject(queryop, "orderby", orderBy, false);
if (hintStr != null)
addToQueryObject(queryop, "$hint", hintStr);
Expand All @@ -117,7 +124,7 @@ public DBObject get(){
return queryop;
}

return query;
return lclQuery;
}

private boolean hasSpecialQueryFields(){
Expand Down

0 comments on commit 19b5eca

Please sign in to comment.