Add type definitions to delete_all
Fix types definitions for delete_all methods.
Changed the return type of delete_all methods to Integer.
@kazuyainoue0124 Thanks for your contribution!
Please follow the instructions below for each change. See also: https://github.com/ruby/gem_rbs_collection/blob/main/docs/CONTRIBUTING.md
Available commands
You can use the following commands by commenting on this PR.
/merge: Merge this PR if CI passes
activerecord
You changed RBS files for an existing gem. You need to get approval from the reviewers of this gem.
@hibariya, @ksss, @Little-Rubyist, please review this pull request.
If this change is acceptable, please make a review comment including APPROVE from here.
After that, the PR author or the reviewers can merge this PR.
Just comment /merge to merge this PR.
FYI: API doc mentions the return value of #delete_all.
Returns the number of rows affected. https://api.rubyonrails.org/classes/ActiveRecord/Relation.html#method-i-delete_all
I noticed ActiveRecord::Associations::CollectionProxy#delete_all takes an optional argument dependent. But ActiveRecord::Associations::Relation#delete_all does not take arguments at all.
But the current design of rbs_rails expects both to be the same.
Therefore it's not good to modify definitions under activerecord.rbs (ActiveRecord::Relation::Methods, ActiveRecord::Base::ClassMethods, _ActiveRecord_Relation and _ActiveRecord_Relation_ClassMethods).
It's better to change only the return types of these methods under activerecord.rbs. And we need to hack rbs_rails to override the argument type of CollectionProxy#delete_all via rbs_rails like https://github.com/pocke/rbs_rails/pull/289 does.
Refs:
- https://api.rubyonrails.org/classes/ActiveRecord/Associations/CollectionProxy.html#method-i-delete_all
- https://api.rubyonrails.org/classes/ActiveRecord/Relation.html#method-i-delete_all
Thank you for your valuable feedback.
I apologize for not fully understanding the differences between ActiveRecord::Associations::CollectionProxy#delete_all and ActiveRecord::Associations::Relation#delete_all, as well as the specifics of rbs_rails.
In this pull request, I have only updated the return types.
I will address the override of CollectionProxy#delete_all in rbs_rails separately.
If there are any remaining issues, please let me know.
Sorry for the delay in responding.
- When modifying 6.0/activerecord-generated.rbs, move as far as possible to 6.0/activerecord.rbs.
- I would like at least one line of testing.