Skip to content

Commit

Permalink
fix(incremental sync): added more comments and fix variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
chobits committed Oct 31, 2024
1 parent 662da5d commit 6813314
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions kong/db/declarative/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ local function _set_entity_for_txn(t, entity_name, item, options, is_delete)
local is_foreign = fdata.type == "foreign"
local fdata_reference = fdata.reference
local value = item[fname]
local fws_id = fdata.unique_across_ws and kong.default_workspace or ws_id
-- avoid overriding the outer ws_id
local field_ws_id = fdata.unique_across_ws and kong.default_workspace or ws_id

-- value may be null, we should skip it
if not value or value == null then
Expand All @@ -346,7 +347,7 @@ local function _set_entity_for_txn(t, entity_name, item, options, is_delete)
value_str = pk_string(kong.db[fdata_reference].schema, value)
end

for _, wid in ipairs {fws_id, GLOBAL_WORKSPACE_TAG} do
for _, wid in ipairs {field_ws_id, GLOBAL_WORKSPACE_TAG} do
local key = unique_field_key(entity_name, wid, fname, value_str or value)

-- store item_key or nil into lmdb
Expand All @@ -360,7 +361,7 @@ local function _set_entity_for_txn(t, entity_name, item, options, is_delete)

value_str = pk_string(kong.db[fdata_reference].schema, value)

for _, wid in ipairs {fws_id, GLOBAL_WORKSPACE_TAG} do
for _, wid in ipairs {field_ws_id, GLOBAL_WORKSPACE_TAG} do
local key = foreign_field_key(entity_name, wid, fname, value_str, pk)

-- store item_key or nil into lmdb
Expand Down

0 comments on commit 6813314

Please sign in to comment.