Skip to content

Commit

Permalink
[API] Generator: Fixes order of arguments.clone
Browse files Browse the repository at this point in the history
When updating the code generator for 8.x, the order of
`arguments.clone` in the generated code was changed. This would make
it so that we would modify the arguments before cloning them, which is
undesired.

Addresses #1727
  • Loading branch information
picandocodigo committed Apr 4, 2022
1 parent 2bc1f2b commit fdad456
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 0 additions & 1 deletion elasticsearch-api/utils/thor/templates/_method_setup.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
# specific language governing permissions and limitations
# under the License.
%>
<%= ' '*(@namespace_depth+4) %>arguments = arguments.clone
<%- if @method_name == 'search' -%>
arguments[:index] = UNDERSCORE_ALL if ! arguments[:index] && arguments[:type]
<%- end -%>
Expand Down
2 changes: 2 additions & 0 deletions elasticsearch-api/utils/thor/templates/method.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ module Elasticsearch
<%= ' '*(@namespace_depth+2) %>end
<%- else -%>
<%- if @method_name == 'get_field_mapping' %>
arguments = arguments.clone
_fields = arguments.delete(:field) || arguments.delete(:fields)
raise ArgumentError, "Required argument 'field' missing" unless _fields
<%- else -%>
<%- @required_parts.each do |required| %><%# Arguments -%>
<%= ' '*(@namespace_depth+3) + "raise ArgumentError, \"Required argument '#{required}' missing\" unless arguments[:#{required}]" + "\n" -%>
<%- end -%>
arguments = arguments.clone
<%- end -%>
headers = arguments.delete(:headers) || {}
<%- #Body %>
Expand Down

0 comments on commit fdad456

Please sign in to comment.