Skip to content

Commit e5d3bac

Browse files
authored
Merge pull request rails#51431 from fcce/fix-load_async-query_cache
Fix load_async to work with query cache
2 parents af773ae + c1c07b0 commit e5d3bac

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

activerecord/lib/active_record/future_result.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ def self.wrap(result)
6060
end
6161

6262
delegate :empty?, :to_a, to: :result
63-
delegate_missing_to :result
6463

6564
attr_reader :lock_wait
6665

activerecord/test/cases/relation/load_async_test.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ def test_pluck
217217
assert_equal titles, Post.where(author_id: 1).load_async.pluck(:title)
218218
end
219219

220+
def test_count
221+
count = Post.where(author_id: 1).count
222+
assert_equal count, Post.where(author_id: 1).load_async.count
223+
end
224+
220225
def test_size
221226
expected_size = Post.where(author_id: 1).size
222227

@@ -233,12 +238,19 @@ def test_empty?
233238
assert_predicate deferred_posts, :loaded?
234239
end
235240

236-
def test_load_async_with_query_cache
241+
def test_load_async_pluck_with_query_cache
237242
titles = Post.where(author_id: 1).pluck(:title)
238243
Post.cache do
239244
assert_equal titles, Post.where(author_id: 1).load_async.pluck(:title)
240245
end
241246
end
247+
248+
def test_load_async_count_with_query_cache
249+
count = Post.where(author_id: 1).count
250+
Post.cache do
251+
assert_equal count, Post.where(author_id: 1).load_async.count
252+
end
253+
end
242254
end
243255

244256
class LoadAsyncNullExecutorTest < ActiveRecord::TestCase

0 commit comments

Comments
 (0)