Skip to content
Browse files

Add spec and update CHANGELOG for identity_map many_to_many fix

  • Loading branch information...
2 parents fa47990 + 4d01c39 commit 6c0950d5ee87e245d5ffa85fff294550f288c786 @jeremyevans committed Jan 17, 2013
Showing with 6 additions and 2 deletions.
  1. +2 −0 CHANGELOG
  2. +1 −0 lib/sequel/plugins/identity_map.rb
  3. +3 −2 spec/extensions/identity_map_spec.rb
View
2 CHANGELOG
@@ -1,5 +1,7 @@
=== HEAD
+* Fix use of identity_map plugin with many_to_many associations with right composite keys (jeremyevans) (#603)
+
* Increase virtual row performance by using a shared VirtualRow instance (jeremyevans)
* Allow the :dataset association option to accept the association reflection as an argument (jeremyevans)
View
1 lib/sequel/plugins/identity_map.rb
@@ -52,6 +52,7 @@ def associate(type, name, opts = {}, &block)
uses_lcks = opts[:uses_left_composite_keys]
uses_rcks = opts[:uses_right_composite_keys]
right = opts[:right_key]
+ rcks = opts[:right_keys]
join_table = opts[:join_table]
left = opts[:left_key]
lcks = opts[:left_keys]
View
5 spec/extensions/identity_map_spec.rb
@@ -282,9 +282,10 @@ class ::IdentityMapArtist < ::IdentityMapModel
it "should work correctly when eagerly loading many_to_many associations with composite keys" do
@c1.columns :id, :id2
- @c2.columns :id
+ @c2.columns :id, :id2
@c1.set_primary_key :id, :id2
- @c1.many_to_many :artists, :class=>@c2, :left_key=>[:album_id1, :album_id2], :right_key=>:artist_id, :join_table=>:aa
+ @c2.set_primary_key :id, :id2
+ @c1.many_to_many :artists, :class=>@c2, :left_key=>[:album_id1, :album_id2], :right_key=>[:artist_id1, :artist_id2], :join_table=>:aa
@c1.dataset._fetch = [{:id=>1, :id2=>4}, {:id=>2, :id2=>5}, {:id=>3, :id2=>6}]
@c2.dataset._fetch = [ {:id=>1, :x_foreign_key_0_x=>1, :x_foreign_key_1_x=>4}, {:id=>1, :x_foreign_key_0_x=>2, :x_foreign_key_1_x=>5}, {:id=>2, :x_foreign_key_0_x=>1, :x_foreign_key_1_x=>4}, {:id=>2, :x_foreign_key_0_x=>2, :x_foreign_key_1_x=>5}, {:id=>3, :x_foreign_key_0_x=>1, :x_foreign_key_1_x=>4}, {:id=>3, :x_foreign_key_0_x=>1, :x_foreign_key_1_x=>4}]

0 comments on commit 6c0950d

Please sign in to comment.
Something went wrong with that request. Please try again.