diff --git a/kong/db/schema/others/declarative_config.lua b/kong/db/schema/others/declarative_config.lua index 42b165f7e7ff..666b340bb898 100644 --- a/kong/db/schema/others/declarative_config.lua +++ b/kong/db/schema/others/declarative_config.lua @@ -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, ":")