
Weird behavior in associations
Reported by Kengo Matsuyama | August 27th, 2009 @ 02:16 AM | in 0.10.0
I met a weird behavior in associations.
class Foo
include DataMapper::Resource
property :id, Serial
has n, :bars
end
class Bar
include DataMapper::Resource
property :id, Serial
property :value, Integer
belongs_to :foo
end
DataMapper.auto_migrate!
Foo.create.tap {|foo|
foo.bars.create(:value => 1)
foo.bars.create(:value => 1)
}
Foo.create.tap {|foo|
foo.bars.create(:value => 1)
}
foos = Foo.all
foos.inspect # ???
p foos[1].bars.first(:value => 1)
#=> #<Bar id=1 value=1 foo_id=1> # expecetd: foo_id=2
p foos[1]
#=> #<Foo id=2>
foos = Foo.all
p foos[1].bars.first(:value => 1)
#=> #<Bar id=3 value=1 foo_id=2> # correct
p foos[1]
#=> #<Foo id=2>
The result is different when inspect is called.
Is this a known bug?
I'm using dm-core 0.9.11, data_objects 0.9.12 and ruby 1.8.7.
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) August 27th, 2009 @ 07:34 AM
- Milestone set to 0.10.0
- State changed from new to resolved
Kengo,
This is resolved on latest next branches. Have a look at http://pastie.org/596560 to confirm that.
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »