Skip to content

Commit

Permalink
TEIID-4381 correcting count 0
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Jul 14, 2017
1 parent cec25b8 commit 1b94659
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Expand Up @@ -527,13 +527,12 @@ private boolean processOptions(int skip, int top, Entity expandEntity) {
return false;
}

if (top > 0 ) {
if (top > -1 ) {
if (this.topCount < top) {
this.topCount++;
return true;
} else {
return false;
}
}
return false;
}
return true;
}
Expand Down
Expand Up @@ -34,7 +34,7 @@
public class ExpandDocumentNode extends DocumentNode {
private String navigationName;
private boolean collection;
private int top;
private int top=-1;
private int skip;
private boolean calculateCount;

Expand Down
24 changes: 23 additions & 1 deletion olingo/src/test/java/org/teiid/olingo/TestODataIntegration.java
Expand Up @@ -2286,7 +2286,29 @@ public void testExpand() throws Exception {
+ "\"Orders_FK0\":[{\"id\":7,\"customerid\":3,\"place\":\"town\"},"
+ "{\"id\":8,\"customerid\":3,\"place\":\"town\"}]},"
+ "{\"id\":4,\"name\":\"customer4\",\"Orders_FK0\":[]}]}",
response.getContentAsString());
response.getContentAsString());

response = http.newRequest(baseURL + "/northwind/m/Customers?$expand=Orders_FK0($top=0;$count=true)&$count=true")
.method("GET")
.send();
assertEquals(200, response.getStatus());
assertEquals("{\"@odata.context\":\"$metadata#Customers\","
+ "\"@odata.count\":4,\""
+ "value\":["
+ "{\"id\":1,\"name\":\"customer1\","
+ "\"Orders_FK0@odata.count\":4,"
+ "\"Orders_FK0\":[]},"
+ "{\"id\":2,\"name\":\"customer2\","
+ "\"Orders_FK0@odata.count\":2,"
+ "\"Orders_FK0\":[]},"
+ "{\"id\":3,\"name\":\"customer3\","
+ "\"Orders_FK0@odata.count\":2,"
+ "\"Orders_FK0\":[]},"
+ "{\"id\":4,\"name\":\"customer4\","
+ "\"Orders_FK0@odata.count\":0,"
+ "\"Orders_FK0\":["
+ "]}]}",
response.getContentAsString());
} finally {
localClient = null;
teiid.undeployVDB("northwind");
Expand Down

0 comments on commit 1b94659

Please sign in to comment.