Skip to content

Commit

Permalink
Revert "Optimize ActiveRecord::Relation#exists? with no conditions …
Browse files Browse the repository at this point in the history
…for loaded relations"
  • Loading branch information
byroot authored Jun 1, 2024
1 parent 0378b05 commit 3b24787
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 14 deletions.
1 change: 0 additions & 1 deletion activerecord/lib/active_record/relation/finder_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ def exists?(conditions = :none)
end

return false if !conditions || limit_value == 0
return !records.empty? if conditions == :none && loaded?

if eager_loading?
relation = apply_join_dependency(eager_loading: false)
Expand Down
13 changes: 0 additions & 13 deletions activerecord/test/cases/finder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,6 @@ def test_exists_returns_true_with_one_record_and_no_args
assert_equal true, Topic.exists?
end

def test_exists_with_loaded_relation
topics = Topic.all.load
assert_no_queries do
assert_equal true, topics.exists?
end

Topic.delete_all
topics = Topic.all.load
assert_no_queries do
assert_equal false, topics.exists?
end
end

def test_exists_returns_false_with_false_arg
assert_equal false, Topic.exists?(false)
end
Expand Down

0 comments on commit 3b24787

Please sign in to comment.