Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(incremental sync): fixed ws_id processing in _set_entity_for_txn #13816

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions kong/db/declarative/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +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]
-- 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 @@ -345,11 +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

if fdata.unique_across_ws then
ws_id = kong.default_workspace
end

for _, wid in ipairs {ws_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 @@ -363,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 {ws_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
Loading