Skip to content

Commit 9601c2e

Browse files
authored
Merge pull request rails#50492 from fatkodima/fix-load_async-query_cache
Fix `load_async` to work with query cache
2 parents f645ff9 + 6d70c7e commit 9601c2e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

activerecord/lib/active_record/future_result.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def flush
4848
Canceled = Class.new(ActiveRecordError)
4949

5050
delegate :empty?, :to_a, to: :result
51+
delegate_missing_to :result
5152

5253
attr_reader :lock_wait
5354

activerecord/test/cases/relation/load_async_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,13 @@ def test_empty?
232232
assert_equal false, deferred_posts.empty?
233233
assert_predicate deferred_posts, :loaded?
234234
end
235+
236+
def test_load_async_with_query_cache
237+
titles = Post.where(author_id: 1).pluck(:title)
238+
Post.cache do
239+
assert_equal titles, Post.where(author_id: 1).load_async.pluck(:title)
240+
end
241+
end
235242
end
236243

237244
class LoadAsyncNullExecutorTest < ActiveRecord::TestCase

0 commit comments

Comments
 (0)