Uploaded image for project: 'Chalmers'
  1. Chalmers
  2. CHAL-294

Query request where offset value > totalRecords returns 0 reords even if actual number of records > totalRecords




      Steps to reproduce

      (It should be able to reproduce them using only item-storage/items, but this is the actual scenario I had.)

      1. With /item-storage/items: Using consecutive queries and paging through the results with a limit 1000 and an offset that increments by 1000 for each query, fetch all existing items where (effectiveLocationId=="f4c5afee-261a-43d1-9708-cc123aaba50a")
      2. With /inventory/items: Using consecutive queries and paging through the results with a limit 100 and an offset that increments by 100 for each query, fetch all existing items where (effectiveLocationId=="f4c5afee-261a-43d1-9708-cc123aaba50a")

      Expected result

      All items matching the criterium are returned. mod-invetory and mod-inventory-storage return the same number of items.

      Actual result

      mod-inventory-storage returns 11 351 items, mod-inventory only 11 000. Not only is the latter number too low, but it's suspiciously even. N.B. that these numbers come from counting the actual records returned, not from the totalRecords value. The totalRecords value returned is, in both cases, 11 075.


      Knowing that mod-inventory-storage returns 11 351 items matching this criterium, let's make this request in Postman:


      It should return records 11 100-11 200. Alas, instead it returns this:

        "items": [],
        "totalRecords": 11075

      Could this have something to do with the fact that our offset value (11 100) is higher than the estimated totalRecords (11 075).

      Let's test that idea by lowering the offset to 11 000, and changing the limit to 400, so that the range encompasses the actual number of records. Lo and behold, this returns 351 items. (totalRecords is still 11075.)


      If the offset value is higher than totalRecords, the query request will return 0 items even if there are actually more records.


      In many cases this probably wouldn't be noticeable, but if the limit used (in order to avoid too long query string errors) is less than the difference
      actual number of records - totalRecords, how do you get to those last records?
      For example this query


      If I set the limit to a higher value the request will return a 500 error.
      totalRecords is 11075, but the actual number of records is 11351. (I know the actual number of records because I tried the same query but with a higher limit in item-storage.)
      The first 111 requests, with offsets between 0 and 11000 return 100 items each. But then I get to


      which returns an empty items list.


        1. loans.png
          85 kB
        2. loans-2.png
          40 kB
        3. screenshot-1.png
          69 kB
        4. screenshot-2.png
          82 kB
        5. screenshot-3.png
          181 kB

        Issue Links



              charlotte Charlotte Whitt
              lisams Lisa Sjögren (EBSCO)
              0 Vote for this issue
              5 Start watching this issue