Skip to content

Commit

Permalink
fixup! refactor(shorthand_fields): remove translate_backwards in favo…
Browse files Browse the repository at this point in the history
…r of replaced_with

PR Review
  • Loading branch information
nowNick committed Sep 27, 2024
1 parent 48ab454 commit 5648799
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions kong/db/schema/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1805,11 +1805,13 @@ function Schema:process_auto_fields(data, context, nulls, opts)
end
end

if is_select and sdata.deprecation and sdata.deprecation.replaced_with and #sdata.deprecation.replaced_with > 0 and not(opts and opts.hide_shorthands) then
if sdata.deprecation.replaced_with[1].reverse_mapping_function then
data[sname] = sdata.deprecation.replaced_with[1].reverse_mapping_function(data)
if is_select and not(opts and opts.hide_shorthands) then
local replaced_with = sdata.deprecation and sdata.deprecation.replaced_with and
sdata.deprecation.replaced_with[1]
if replaced_with.reverse_mapping_function then
data[sname] = replaced_with.reverse_mapping_function(data)
else
data[sname] = table_path(data, sdata.deprecation.replaced_with[1].path)
data[sname] = table_path(data, replaced_with.path)
end
end
end
Expand Down Expand Up @@ -1963,8 +1965,12 @@ function Schema:process_auto_fields(data, context, nulls, opts)

if self.shorthand_fields then
for _, shorthand_field in ipairs(self.shorthand_fields) do
if shorthand_field[key] and shorthand_field[key].deprecation and shorthand_field[key].deprecation.replaced_with and #shorthand_field[key].deprecation.replaced_with > 0 then
should_be_in_ouput = is_select
if shorthand_field[key] then
local replaced_with = shorthand_field[key].deprecation and shorthand_field[key].deprecation.replaced_with and
#shorthand_field[key].deprecation.replaced_with[1]
if replaced_with then
should_be_in_ouput = is_select
end
end
end
end
Expand Down

0 comments on commit 5648799

Please sign in to comment.