Deprecate the delegation of Array bang methods in ActiveRecord::Delegation #12129

Merged
merged 2 commits into from Sep 13, 2013

Conversation

Projects
None yet
3 participants
Contributor

Empact commented Sep 4, 2013

The primary means of returning results for Array bang methods is to modify
the array in-place. When you call these methods on a relation, that
array is created, modified, and then thrown away. Only the secondary
return value is exposed to the caller.

Removing this delegation is a straight-forward way to reduce user error
by forcing callers to first explicitly call #to_a in order to expose
the array to be acted on by the bang method.

Empact added some commits Sep 4, 2013

@Empact Empact Pull the RelationMutationTests from cases/relation_test to cases/rela…
…tion/mutation_test.
5e41cb4
@Empact Empact Deprecate the delegation of Array bang methods in ActiveRecord::Deleg…
…ation

The primary means of returning results for Array bang methods is to modify
the array in-place. When you call these methods on a relation, that
array is created, modified, and then thrown away. Only the secondary
return value is exposed to the caller.

Removing this delegation is a straight-forward way to reduce user error
by forcing callers to first explicitly call #to_a in order to expose
the array to be acted on by the bang method.
1a40be0
Owner

rafaelfranca commented Sep 13, 2013

Make sense

rafaelfranca merged commit 1a40be0 into rails:master Sep 13, 2013

1 check passed

default The Travis CI build passed
Details

Empact deleted the Empact:deprecate-array-bang-delegation branch Sep 13, 2013

delete_if() is also an in-place modification method - judging just by bang name is not reliable enough!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment