Skip to content

Commit

Permalink
Fix load_async to work with query cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima committed Dec 30, 2023
1 parent 0fb5f67 commit 6d70c7e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions activerecord/lib/active_record/future_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def flush
Canceled = Class.new(ActiveRecordError)

delegate :empty?, :to_a, to: :result
delegate_missing_to :result

attr_reader :lock_wait

Expand Down
7 changes: 7 additions & 0 deletions activerecord/test/cases/relation/load_async_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ def test_empty?
assert_equal false, deferred_posts.empty?
assert_predicate deferred_posts, :loaded?
end

def test_load_async_with_query_cache
titles = Post.where(author_id: 1).pluck(:title)
Post.cache do
assert_equal titles, Post.where(author_id: 1).load_async.pluck(:title)
end
end
end

class LoadAsyncNullExecutorTest < ActiveRecord::TestCase
Expand Down

0 comments on commit 6d70c7e

Please sign in to comment.