Project

General

Profile

« Previous | Next » 

Revision 54661

Fixed bug in CQL translation to mongo queries when dealing with exist queries like fieldname = *

View differences:

MongoCqlTranslator.java
59 59
	}
60 60

  
61 61
	private Bson doTranslate(final CQLTermNode termNode) throws CQLParseException {
62
		if (termNode.getTerm().equals("*")) return new BasicDBObject();
62
		if (termNode.getTerm().equals("*")  && (termNode.getIndex().equals("*") || termNode.getIndex().equals("cql.serverChoice"))) return new BasicDBObject();
63 63
		String relation = termNode.getRelation().getBase();
64 64
		Relation rel = Relations.get(relation);
65 65
		return this.handleRelationNode(rel, termNode);
......
80 80
		switch (rel) {
81 81
		case EQUAL:
82 82
		case EXACT:
83
			mongoQueryObject.put(indexName, termObj);
83
			if(!term.equals("*")) {
84
				mongoQueryObject.put(indexName, termObj);
85
			}
86
			else{
87
				//special case to handle exist queries such as fieldname = * --> qty: { $exists: true}
88
				mongoQueryObject.put(indexName, new BasicDBObject("$exists", true));
89
			}
84 90
			break;
85 91
		case NOT:
86 92
			mongoQueryObject.put(indexName, new BasicDBObject("$ne", termObj));

Also available in: Unified diff