Skip to content

Commit 9efe4e8

Browse files
authored
Merge pull request #677 from bserdar/671
671
2 parents cb672cf + 2b61bb5 commit 9efe4e8

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

crud/src/main/java/com/redhat/lightblue/assoc/ep/Copy.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public StepResult<ResultDocument> getResults(ExecutionContext ctx) {
4444
public Stream<ResultDocument> stream() {
4545
// Create new documents for each document in the source. This will
4646
// create the correct slots based on this execution block
47-
return super.stream().map(d -> new ResultDocument(block, d.getDoc()));
47+
return super.stream().map(d -> {
48+
if(recordResultSetSize)
49+
ctx.incMatchCount();
50+
return new ResultDocument(block, d.getDoc());
51+
});
4852
}
4953
};
5054
}

crud/src/main/java/com/redhat/lightblue/assoc/ep/ExecutionContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public void setMatchCount(int c) {
5555
matchCount = c;
5656
}
5757

58+
public void incMatchCount() {
59+
matchCount++;
60+
}
61+
5862
public void close() {
5963
executor.shutdown();
6064
}

crud/src/test/java/com/redhat/lightblue/mediator/CompositeFinderTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,16 @@ public void rev_search_with_arraycond() throws Exception {
592592
Assert.assertEquals(2, response.getEntityData().get(0).get("us").size());
593593
}
594594

595+
@Test
596+
public void rev_search_with_arraycond_matchcount() throws Exception {
597+
FindRequest fr = new FindRequest();
598+
fr.setQuery(query("{'array':'us.*.authentications','elemMatch':{ '$and':[ { 'field':'principal','op':'$in','values':['a']}, {'field':'providerName','op':'$eq','rvalue':'p'} ] } }"));
599+
fr.setProjection(projection("[{'field':'*','recursive':1},{'field':'us','recursive':1}]"));
600+
fr.setEntityVersion(new EntityVersion("L", "0.0.1"));
601+
Response response = mediator.find(fr);
602+
Assert.assertEquals(1, response.getMatchCount());
603+
}
604+
595605
@Test
596606
public void elem_match_forward() throws Exception {
597607
FindRequest fr = new FindRequest();

0 commit comments

Comments
 (0)