Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2443#discussion_r170600330
  
    --- Diff: 
nifi-nar-bundles/nifi-mongodb-bundle/nifi-mongodb-processors/src/main/java/org/apache/nifi/processors/mongodb/GetMongo.java
 ---
    @@ -236,12 +261,33 @@ public void onTrigger(final ProcessContext context, 
final ProcessSession session
                         
context.getProperty(QUERY).evaluateAttributeExpressions().getValue());
             }
     
    -        final Document query = context.getProperty(QUERY).isSet()
    -                ? 
Document.parse(context.getProperty(QUERY).evaluateAttributeExpressions().getValue())
 : null;
    +        final Document query;
    +        if (context.getProperty(QUERY).isSet()) {
    +            String queryStr = 
context.getProperty(QUERY).evaluateAttributeExpressions(input).getValue();
    +            query = Document.parse(queryStr);
    +        } else if (!context.getProperty(QUERY).isSet() && input == null) {
    +            query = Document.parse("{}");
    --- End diff --
    
    The documentation for the Query property says that if there is no incoming 
connection and Query is not set, then it results in an error. But this like 
issues an empty query which appears to fetch all results.
    
    Also please check line 234 above, looks like we need to do that later, 
after "queryStr" is populated for example. Currently the Query Attribute will 
not be populated if there is an incoming flow file.


---

Reply via email to