-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Revert "refactor(shorthand_fields): remove translate_backwards in favor of replaced_with (#13604)" #14477
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
base: master
Are you sure you want to change the base?
Conversation
1348bf1
to
c4edf4f
Compare
c4edf4f
to
1b6cc07
Compare
1b6cc07
to
ebd495a
Compare
if new_field_value and | ||
new_field_value ~= ngx.null and | ||
not deepcompare(new_field_value, shorthand_value) then | ||
local new_field_name = join_string(".", replaced_with_element.path) | ||
new_field_value ~= ngx.null and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it make sense to turn this check into an early return?
I meant to highlight:
if new_field_value and
new_field_value ~= ngx.null and
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I quite follow what you mean 🤔 - could you give me an example of this early return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant instead of doing a long condition for the if
maybe do:
if not new_field_value or new_field_value == ngx.null then
return true
end
just to make it a bit more readable. I haven't thoroughly checked if this is the right logic and I'm not sure if it's a good idea here, you're more familiar with the logic to make the best decision - feel free to disregard, it's an extra minor comment.
spec/02-integration/03-db/23-shorthand_fields_translate_backwards_spec.lua
Outdated
Show resolved
Hide resolved
ebd495a
to
157c021
Compare
157c021
to
9610847
Compare
Summary
This partially reverts commit 11405e5. (not all changes were added back again)
translate_backwards
was an udocumented experimental API that was created in order to generate API responses that were backwards compatible after plugin's schema field rename. It was later replaced bydeprecation.replaced_with
field in the schema. In the meantime it had been used by some custom plugins that rely on this field. Hence the reason why we need to bring it back - in order for those custom plugins to work.Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
KAG-6947