forrestzhu / odata4j

Automatically exported from code.google.com/p/odata4j
0 stars 0 forks source link

$top param value in the next url is wrong #94

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I am using the InMemoryProducer and the default maxResults value in this is 100.
For eg: If I call the service URL - <URL>?$skip=0&$top=150, the response 
contains 100 entitities and the next URL - 
<URL>?$skip=0&$top=150&skiptoken<token>

What is the expected output? What do you see instead?
Instead, the $top value here should have been reduced by the number of values 
already returned and the next URL should have been - 
<URL>?$skip=0&$top=50&skiptoken<token>

Please provide any additional information below.
I checked the implementation of AtomFeedFormatWriter. Here only the $skipToken 
parameter is updated and not the $top.

Original issue reported on code.google.com by radhikab...@gmail.com on 25 Nov 2011 at 12:42

GoogleCodeExporter commented 8 years ago
I will take a look into this issue.

Original comment by stoy...@gmail.com on 21 Sep 2012 at 10:43

GoogleCodeExporter commented 8 years ago
I was able to reproduce and fix the issue, see the attached patch. I also added 
a unit test.

While testing, I noticed that there seems to be also this issue: next url with 
a $skiptoken is generated even if the requested $top value is smaller than the 
default maxResults, i.e. when running the InMemoryProducerTest and querying 
http://localhost:8887/InMemoryProducerExample.svc/Integers?$top=1 that still 
produces a next url: <link rel="next" 
href="http://localhost:8887/InMemoryProducerExample.svc/Integers?$skiptoken=(0)"
 />. All other OData services I checked (Netflix, Northwind, etc.) don't do 
this. Should this be fixed as well?

Original comment by stoy...@gmail.com on 21 Sep 2012 at 2:50

Attachments:

GoogleCodeExporter commented 8 years ago
Patch looks good. It's committed. Thanks.

Original comment by stephan....@googlemail.com on 24 Sep 2012 at 10:07

GoogleCodeExporter commented 8 years ago
I'm not sure if I did misunderstood the term maxResult. maxResults is the 
maximum result-set that a server can return in one request. There are even more 
results to return with next link and actually this means server side paging.

With client side paging it became more complicated and we have to consider the 
cases where top > maxResult. Here is an use case:

result set: 20
maxResult:   8
top:        10

How will the next link after first request with top=10 look like?

Original comment by stephan....@googlemail.com on 25 Sep 2012 at 12:49

GoogleCodeExporter commented 8 years ago
When top > maxResult, the next link was generated with a long "top" value, as 
reported in the issue. This is now fixed. In your example, before the fix it 
would have been:
<link rel="next" href="...?$top=10&;$skiptoken=(7)" />
After the fix, it would be:
<link rel="next" href="...?$top=2&;$skiptoken=(7)" />

The other issue that I see is when top < maxResult. In this case, odata4j still 
generates a next link, although I believe it shouldn't, and all other services 
I tested don't do this as well.

Original comment by stoy...@gmail.com on 30 Sep 2012 at 11:11