Skip to content

Commit

Permalink
Fixed Relation loaded error for non-mutating methods on relation - #1395
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 7, 2022
1 parent 8a0303c commit e05728d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Added `model` method to `Searchkick::Relation`
- Fixed deprecation warning with `redis` gem
- Fixed `respond_to?` method on relation loading relation
- Fixed `Relation loaded` error for non-mutating methods on relation

## 5.0.4 (2022-06-16)

Expand Down
5 changes: 5 additions & 0 deletions lib/searchkick/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,10 @@ def check_loaded
def ensure_permitted(obj)
obj.to_h
end

def initialize_copy(other)
super
@execute = nil
end
end
end
3 changes: 3 additions & 0 deletions test/relation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ def test_loaded
refute products.loaded?
assert_equal 0, products.count
assert products.loaded?
refute products.clone.loaded?
refute products.dup.loaded?
refute products.limit(2).loaded?
error = assert_raises(Searchkick::Error) do
products.limit!(2)
end
Expand Down

0 comments on commit e05728d

Please sign in to comment.