Skip to content

Commit

Permalink
change lmdb key format
Browse files Browse the repository at this point in the history
11-declarative_lmdb_spec.lua

fix spec/01-unit/01-db/10-declarative_spec.lua
  • Loading branch information
chronolaw committed Oct 22, 2024
1 parent 2e80332 commit 522dbf3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions kong/db/declarative/import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ end


local function unique_field_key(schema_name, ws_id, field, value)
return string_format("%s|%s|%s|%s", schema_name, ws_id, field, sha256_hex(value))
return string_format("%s|%s|%s|%s", schema_name, field, ws_id, sha256_hex(value))
end


local function foreign_field_key_prefix(schema_name, ws_id, field, foreign_id)
return string_format("%s|%s|%s|%s|", schema_name, ws_id, field, foreign_id)
return string_format("%s|%s|%s|%s|", schema_name, field, ws_id, foreign_id)
end


Expand All @@ -243,7 +243,7 @@ local function foreign_field_key(schema_name, ws_id, field, foreign_id, pk)
end

local function item_key_prefix(schema_name, ws_id)
return string_format("%s|%s|*|", schema_name, ws_id)
return string_format("%s|*|%s|", schema_name, ws_id)
end


Expand Down
4 changes: 2 additions & 2 deletions spec/01-unit/01-db/10-declarative_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ keyauth_credentials:
it("utilizes the schema name, workspace id, field name, and checksum of the field value", function()
local key = unique_field_key("services", "123", "fieldname", "test", false)
assert.is_string(key)
assert.equals("services|123|fieldname|" .. sha256_hex("test"), key)
assert.equals("services|fieldname|123|" .. sha256_hex("test"), key)
end)

-- since incremental sync the param `unique_across_ws` is useless
-- this test case is just for compatibility
it("does not omits the workspace id when 'unique_across_ws' is 'true'", function()
local key = unique_field_key("services", "123", "fieldname", "test", true)
assert.equals("services|123|fieldname|" .. sha256_hex("test"), key)
assert.equals("services|fieldname|123|" .. sha256_hex("test"), key)
end)
end)

Expand Down
8 changes: 4 additions & 4 deletions spec/01-unit/01-db/11-declarative_lmdb_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ describe("#off preserve nulls", function()

-- format changed after incremental sync
local cache_key = concat({
"basicauth_credentials|",
"basicauth_credentials|*|",
item.ws_id,
"|*|",
"|",
id
})

Expand All @@ -227,9 +227,9 @@ describe("#off preserve nulls", function()

-- format changed after incremental sync
cache_key = concat({
"plugins|",
"plugins|route|",
plugin.ws_id,
"|route|",
"|",
plugin.route.id,
"|",
plugin.id
Expand Down

0 comments on commit 522dbf3

Please sign in to comment.