Skip to content

Commit

Permalink
fix(sync/lmdb): construct right pk string for entity with multiple pr…
Browse files Browse the repository at this point in the history
…imary keys

For the entity with multiple primary keys, like consumer_group_consumers, the
pk_string() function construct incorrect pk string like
`table: 0x028a49eda0:table: 0x0289c257b8`. Because it does not extract the
internal id value. Here, we fix it with original lmdb logic
get_cache_key_value(). Note this method directly gets id field name.
  • Loading branch information
chobits committed Nov 4, 2024
1 parent 7d71b6b commit c3894f9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion kong/db/schema/others/declarative_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,18 @@ do
end

CACHED_OUT:clear()

-- The logic comes from get_cache_key_value(), which uses `id` directly to
-- extract foreign key.
for i = 1, count do
local k = primary_key[i]
insert(CACHED_OUT, tostring(object[k]))
local v = object[k]

if type(v) == "table" and schema.fields[k].type == "foreign" then
v = v.id
end

insert(CACHED_OUT, tostring(v or ""))
end

return concat(CACHED_OUT, ":")
Expand Down

0 comments on commit c3894f9

Please sign in to comment.