diff --git a/kong/db/schema/init.lua b/kong/db/schema/init.lua index 2659d52d1bd61..5c3dd5512eb92 100644 --- a/kong/db/schema/init.lua +++ b/kong/db/schema/init.lua @@ -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 @@ -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