aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/named_scope.rb
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2010-03-30 10:41:56 -0300
committerJosé Valim <jose.valim@gmail.com>2010-03-30 15:36:18 +0200
commit8d99ec9a4dcef5918c4487a0d94ef0a9622fe8c9 (patch)
treeaeb56a9d16aa9165e2ea5695da43c49da784ce30 /activerecord/lib/active_record/named_scope.rb
parent41b45d56553316f175660fe6e2923409adee37e2 (diff)
downloadrails-8d99ec9a4dcef5918c4487a0d94ef0a9622fe8c9.tar.gz
rails-8d99ec9a4dcef5918c4487a0d94ef0a9622fe8c9.tar.bz2
rails-8d99ec9a4dcef5918c4487a0d94ef0a9622fe8c9.zip
Named scopes shouldn't test equality using to_a if it's not an Array, this was causing records to be loaded before they were needed.
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/named_scope.rb')
-rw-r--r--activerecord/lib/active_record/named_scope.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index aac00cc54a..9abf979cd0 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -167,7 +167,14 @@ module ActiveRecord
end
def ==(other)
- other.respond_to?(:to_ary) ? to_a == other.to_a : false
+ case other
+ when Scope
+ to_sql == other.to_sql
+ when Relation
+ other == self
+ when Array
+ to_a == other.to_a
+ end
end
private