On Jun 24, 7:43 pm, Andy Shipman <[email protected]> wrote:
> >   it "1 to 1 associations appears to be sharing associations across an
> identity map" do
>     other_spouse_object_id =
>       repository(:reloaded) do
>         parent_reloaded = Parent.get(@parent.id)
>         parent_reloaded.spouse.object_id
>       end
>
>     @parent.spouse.object_id.should_not == other_spouse_object_id
>   end
> end

I consider this behaviour a bug - it appears to contradict the
intention of an Identity Map.  It is also inconsistent - the parent
resource gets a unique object, but the children are shared with the
previous identity map.

There is a workaround:

  def with_db_reconnect(&blk)
    original_repository = DataMapper::Repository.context.pop
    repository(:reloaded, &blk)
    DataMapper::Repository.context << original_repository
  end

  it "can be fixed by popping the current repository off the context
stack" do
    other_spouse_object_id =
      with_db_reconnect do
        parent_reloaded = Parent.get(@parent.id)
        parent_reloaded.spouse.object_id
      end

    @parent.spouse.object_id.should_not == other_spouse_object_id
  end

Can anyone confirm that the original behaviour is indeed a bug?  If
so, I'll file a ticket.

Thanks
Ashley
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to