Skip to content
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

Don't emit Ruby warnings when requiring opensearch-dsl #231

Merged
merged 1 commit into from
Mar 3, 2024

Conversation

Earlopain
Copy link
Collaborator

Description

The removed define_method in options.rb just ensured that you are able to use source and _source, that's all this does. The other entries where this isn't a problem are simply overwritten, as you can see from the warnings. Just switch to handwriting this one special case.

The second change removes a option_method :max_expansions from match.rb. This previously appeared twice in the list and also caused a warning.

$ RUBYOPT=-w bundle exec irb
irb(main):001> require "opensearch-dsl"
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old fields
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of fields was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old script_fields
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of script_fields was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old fielddata_fields
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of fielddata_fields was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old rescore
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of rescore was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old explain
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of explain was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old version
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of version was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old indices_boost
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of indices_boost was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old track_scores
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of track_scores was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old min_score
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of min_score was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old track_total_hits
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of track_total_hits was here
opensearch-ruby/lib/opensearch/dsl/search/base_component.rb:75: warning: method redefined; discarding old max_expansions
opensearch-ruby/lib/opensearch/dsl/search/base_component.rb:75: warning: previous definition of max_expansions was here
=> true

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Previous output:
```
$ RUBYOPT=-w bundle exec irb
irb(main):001> require "opensearch-dsl"
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old fields
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of fields was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old script_fields
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of script_fields was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old fielddata_fields
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of fielddata_fields was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old rescore
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of rescore was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old explain
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of explain was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old version
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of version was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old indices_boost
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of indices_boost was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old track_scores
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of track_scores was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old min_score
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of min_score was here
opensearch-ruby/lib/opensearch/dsl/search/options.rb:59: warning: method redefined; discarding old track_total_hits
opensearch-ruby/lib/opensearch/dsl/search/options.rb:55: warning: previous definition of track_total_hits was here
opensearch-ruby/lib/opensearch/dsl/search/base_component.rb:75: warning: method redefined; discarding old max_expansions
opensearch-ruby/lib/opensearch/dsl/search/base_component.rb:75: warning: previous definition of max_expansions was here
=> true
```

Signed-off-by: Earlopain <[email protected]>
@nhtruong
Copy link
Collaborator

nhtruong commented Mar 3, 2024

Woah. Nice catches! Thank you!!

@nhtruong nhtruong merged commit 136e1c9 into opensearch-project:main Mar 3, 2024
66 checks passed
@Earlopain Earlopain deleted the fix-dsl-ruby-warnings branch March 3, 2024 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants