private DBObject translateNaryFieldRelationalExpression(FieldTreeNode context, EntityMetadata md, NaryFieldRelationalExpression expr,MutablePath fullPath) { FieldInfo finfo=resolveFieldForQuery(context,fullPath.immutableCopy(),expr.getField()); Type t = finfo.fieldMd.getType(); if (t.supportsEq()) { if(!fullPath.isEmpty()) { // We are in array elemMatch query, and can't use a $where throw new NeedsJS(); } JSQueryTranslator jstx=new JSQueryTranslator(md); return new BasicDBObject("$where",jstx.translateQuery(expr).toString()); } else { throw Error.get(ERR_INVALID_FIELD, expr.toString()); } }
private DBObject translateNaryFieldRelationalExpression(FieldTreeNode context, NaryFieldRelationalExpression expr) { Type t = resolve(context, expr.getField()).getType(); if (t.supportsEq()) { // Call resolve, which will verify the field exists. Don't need the response. resolve(context,expr.getRfield()); boolean in=expr.getOp()==NaryRelationalOperator._in; return new BasicDBObject("$where", String.format("function() for(var nfr=0;nfr<this.%s.length;nfr++) {if ( %s == %s[nfr] ) return %s;} return %s;}", translateJsPath(expr.getRfield()), translateJsPath(expr.getField()), translateJsPath(expr.getRfield()), in?"true":"false", in?"false":"true")); } else { throw Error.get(ERR_INVALID_FIELD, expr.toString()); } }
FieldTreeNode fieldMd=ctx.contextNode.resolve(query.getField()); if(!fieldMd.getType().supportsEq()) { throw Error.get(ERR_INVALID_COMPARISON, query.toString());