Skip to content

Commit

Permalink
fix(dao): page size 1 does not work for lmdb
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki committed Nov 21, 2024
1 parent 9918f6d commit fb22509
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kong/db/strategies/off/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions spec/02-integration/04-admin_api/07-upstreams_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit fb22509

Please sign in to comment.