diff --git a/kong/db/strategies/off/init.lua b/kong/db/strategies/off/init.lua index a80772224f27..0bdc5eb60229 100644 --- a/kong/db/strategies/off/init.lua +++ b/kong/db/strategies/off/init.lua @@ -131,6 +131,12 @@ local function page_for_prefix(self, prefix, size, offset, options, follow) return nil, err_or_more end + -- special handling for page size 1. + -- drop other results + if size == 1 then + res = { res[1] } + end + local ret = {} local ret_idx = 0 local schema = self.schema diff --git a/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua b/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua index 8012e5d4d849..e356af760ed4 100644 --- a/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua +++ b/spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua @@ -663,6 +663,18 @@ describe("Admin API: #" .. strategy, function() assert.same({ data = {}, next = ngx.null }, json) end) end) + + describe("#regression", function() + it("page size 1", function() + local res = assert(client:send { + method = "GET", + path = "/upstreams?size=1" + }) + assert.response(res).has.status(200) + local json = assert.response(res).has.jsonbody() + assert.equal(1, #json.data) + end) + end) end) describe("DELETE", function()