Revert "Optimize `ActiveRecord::Relation#exists?` with no conditions for loaded relations"

This commit is contained in:
Jean Boussier 2024-06-01 10:35:22 +02:00 committed by GitHub
parent 0378b056de
commit 3b247873e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 0 additions and 14 deletions

View File

@ -365,7 +365,6 @@ module ActiveRecord
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)

View File

@ -285,19 +285,6 @@ class FinderTest < ActiveRecord::TestCase
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