Skip to content

Avoid duplicating definition of ActiveRecord::Relation.destroy_all#2537

Open
reu wants to merge 1 commit intoShopify:mainfrom
reu:remove-duplicate-destroy-all
Open

Avoid duplicating definition of ActiveRecord::Relation.destroy_all#2537
reu wants to merge 1 commit intoShopify:mainfrom
reu:remove-duplicate-destroy-all

Conversation

@reu
Copy link

@reu reu commented Mar 18, 2026

Motivation

destroy_all is defined both as a hardcoded common method (line 612) and dynamically via the RELATION_METHODS loop (line 862), since ActiveRecord::Relation includes destroy_all as an instance method. This results in a duplicated def destroy_all; end signature in the generated RBI files.

Implementation

Added a guard (unless RELATION_METHODS.include? :destroy_all) to the hardcoded destroy_all definition so it is only generated when destroy_all is not already part of RELATION_METHODS. When ActiveRecord includes it in Relation.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_all entries.

Tests

Updated existing specs to reflect the corrected (non-duplicated) output.

@reu reu requested a review from a team as a code owner March 18, 2026 15:03
@reu
Copy link
Author

reu commented Mar 18, 2026

I have signed the CLA!

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.

1 participant