Skip to content

Commit

Permalink
add schema parameter to page_for_prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Nov 21, 2024
1 parent 01ab09b commit 11ef7ba
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions kong/db/strategies/off/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ end
local LMDB_MIN_PAGE_SIZE = 2


local function page_for_prefix(self, prefix, size, offset, options, follow)
local function page_for_prefix(self, prefix, size, offset, options, follow, schema)
if not size then
size = self.connector:get_page_size(options)
end
Expand All @@ -133,9 +133,10 @@ local function page_for_prefix(self, prefix, size, offset, options, follow)

local ret = {}
local ret_idx = 0
local schema = self.schema
local last_key

schema = schema or self.schema

for _, kv in ipairs(res) do
last_key = kv.key
local item, err
Expand Down Expand Up @@ -240,7 +241,7 @@ local function page_for_tags(self, size, offset, options)
end

-- Each page operation retrieves the entities of only one DAO type.
local schema_name, offset_token
local schema_name, offset_token, dao

if offset then
schema_name, offset_token = offset:match("^([^|]+)|(.+)")
Expand All @@ -259,8 +260,6 @@ local function page_for_tags(self, size, offset, options)
end
end

local dao

if offset_token then
-- There are still some entities left from the last page operation that
-- haven't been retrieved, so we need to use the previous dao
Expand All @@ -273,16 +272,8 @@ local function page_for_tags(self, size, offset, options)

local rows, err

-- TODO: need a more elegant solution, page_for_prefix will use
-- self.schema to search entities
local orig_schema = self.schema -- use dao schema instead
self.schema = dao.schema

rows, err, offset_token = page_for_prefix(self, prefix, size, offset_token,
options, true)

self.schema = orig_schema -- restore schema

options, true, dao.schema)
if not rows then
return nil, err
end
Expand Down

0 comments on commit 11ef7ba

Please sign in to comment.