Skip to content

Commit

Permalink
fix(sync): use local table to contain pk strings in pk_string()
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Nov 5, 2024
1 parent 4656916 commit 03f2a1c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 2 additions & 6 deletions kong/db/schema/others/declarative_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ local foreign_children = {}

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

-- 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 @@ -57,10 +52,11 @@ do
return tostring(object[primary_key[1]])
end

tb_clear(CACHED_OUT)
local CACHED_OUT = {}

-- The logic comes from get_cache_key_value(), which uses `id` directly to
-- extract foreign key.
-- TODO: extract primary key recursively using pk_string(), KAG-5750
for i = 1, count do
local k = primary_key[i]
local v = object[k]
Expand Down
4 changes: 4 additions & 0 deletions kong/tools/request_aware_table.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
--- NOTE: tool is designed to assist with **detecting** request contamination
-- issues on CI, during test runs. It does not offer security safeguards.
--
-- In debug mode,
-- 1. `:clear` could not clear elements inserted by `table.insert()`
-- 2. `table.concat()` couldn't work for elements assigned using `indexing`

local table_new = require("table.new")
local table_clear = require("table.clear")
Expand Down

0 comments on commit 03f2a1c

Please sign in to comment.