Skip to content

Commit

Permalink
Merge pull request #459 from Shopify/type-cast-column
Browse files Browse the repository at this point in the history
Stop passing the column to Connection#type_cast
  • Loading branch information
casperisfine authored May 5, 2020
2 parents 0e54659 + 162141c commit fd2f316
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 17 deletions.
1 change: 0 additions & 1 deletion lib/identity_cache/cached/primary_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def load_one_from_db(id)
def load_multi_from_db(ids)
return {} if ids.empty?

ids = ids.map { |id| model.connection.type_cast(id, id_column) }
records = build_query(ids).to_a
model.send(:setup_embedded_associations_on_miss, records)
records.index_by(&:id)
Expand Down
8 changes: 0 additions & 8 deletions test/fetch_multi_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,6 @@ def test_fetch_multi_with_duplicate_ids_in_transaction_returns_results_in_the_or
assert_equal([@joe, @bob, @joe], Item.fetch_multi(@joe.id, @bob.id, @joe.id))
end

def test_load_multi_from_db_coerces_ids_to_primary_key_type
mock_relation = mock("ActiveRecord::Relation")
Item.expects(:where).returns(mock_relation)
mock_relation.expects(:includes).returns(stub(to_a: [@bob, @joe, @fred]))

Item.cached_primary_index.send(:load_multi_from_db, [@bob, @joe, @fred].map(&:id).map(&:to_s))
end

def test_fetch_multi_doesnt_freeze_keys
cache_response = {}
cache_response[@bob_blob_key] = cache_response_for(@bob)
Expand Down
8 changes: 0 additions & 8 deletions test/prefetch_associations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,6 @@ def test_fetch_multi_batch_fetches_non_embedded_second_level_associations_throug
end
end

def test_load_multi_from_db_coerces_ids_to_primary_key_type
mock_relation = mock("ActiveRecord::Relation")
Item.expects(:where).returns(mock_relation)
mock_relation.expects(:includes).returns(stub(to_a: [@bob, @joe, @fred]))

Item.cached_primary_index.send(:load_multi_from_db, [@bob, @joe, @fred].map(&:id).map(&:to_s))
end

def test_fetch_by_index_with_includes_option
Item.send(:cache_belongs_to, :item)
Item.cache_index(:title)
Expand Down

0 comments on commit fd2f316

Please sign in to comment.