Reputation: 18494
This might be a silly question. It's certainly pedantic.
Is there any difference between MyModel.where(...)
and MyModel.where(...).all
?
This question was prompted by a deprecation warning I got a few minutes ago:
DEPRECATION WARNING: This dynamic method is deprecated.
Please use e.g. Post.where(...).all instead.
Is that all
really necessary?
Upvotes: 0
Views: 41
Reputation: 5655
No, they are equivalent, at least in the way you're probably thinking:
Model.where(id: nil) === Model.where(id: nil).all # returns true
Model.where(id: nil) == Model.where(id: nil).all # returns true
Model.where(id: nil).eql? Model.where(id: nil).all # returns false
Model.where(id: nil).equal? Model.where(id: nil).all # returns false
a
, does b
get put in it?.eql?
and .equal?
being false confirms that these are two different objects. Both that their hashes are non-identical and their object identities are non-identicalUpvotes: 2