Avoid duplicating definition of ActiveRecord::Relation.destroy_all#2537
Open
reu wants to merge 1 commit intoShopify:mainfrom
Open
Avoid duplicating definition of ActiveRecord::Relation.destroy_all#2537reu wants to merge 1 commit intoShopify:mainfrom
reu wants to merge 1 commit intoShopify:mainfrom
Conversation
Author
|
I have signed the CLA! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
destroy_allis defined both as a hardcoded common method (line 612) and dynamically via theRELATION_METHODSloop (line 862), sinceActiveRecord::Relationincludesdestroy_allas an instance method. This results in a duplicateddef destroy_all; endsignature in the generated RBI files.Implementation
Added a guard (
unless RELATION_METHODS.include? :destroy_all) to the hardcodeddestroy_alldefinition so it is only generated whendestroy_allis not already part ofRELATION_METHODS. When ActiveRecord includes it inRelation.instance_methods(false), the dynamic loop handles it and the hardcoded one is skipped, avoiding the duplicate.Updated the expected output in the spec to remove the duplicated
destroy_allentries.Tests
Updated existing specs to reflect the corrected (non-duplicated) output.