Skip to content

Commit

Permalink
fix(sync): don't use an upvalue request_aware_table to construct pk_s…
Browse files Browse the repository at this point in the history
…tring (#10623)

* fix(sync): don't use an upvalue request_aware_table to construct pk_string

* fix: use local upvalue {}
  • Loading branch information
chobits committed Nov 5, 2024
1 parent c3894f9 commit 1ac52f4
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions kong/db/schema/others/declarative_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ local foreign_children = {}

do
local tb_nkeys = require("table.nkeys")
local request_aware_table = require("kong.tools.request_aware_table")
local tb_clear = require("table.clear")

local CACHED_OUT
-- We couldn't use "kong.tools.request_aware_table" as an upvalue table here
-- because its :clear() couldn't actually clear its contents in debug mode.
local CACHED_OUT = {}

-- Generate a stable and unique string key from primary key defined inside
-- schema, supports both non-composite and composite primary keys
Expand All @@ -55,11 +57,7 @@ do
return tostring(object[primary_key[1]])
end

if not CACHED_OUT then
CACHED_OUT = request_aware_table.new()
end

CACHED_OUT:clear()
tb_clear(CACHED_OUT)

-- The logic comes from get_cache_key_value(), which uses `id` directly to
-- extract foreign key.
Expand Down

0 comments on commit 1ac52f4

Please sign in to comment.