Howdy,
Got a weird one. Basically two simple models with a resource many-to-
many association. Basically create one model, then create another and
add it to the first one's association. Using an all query, everything
is fine. But if I use a first plus property query, the association
will then have duplicate records on the next all query.
This is data_mapper-1.1.0
Here's the heart of the issue:
it 'should have one requirement when accessed via all' do
@p1.requirements.all(:description => 'be the best').size.should ==
1
@p1.requirements.all.size.should == 1
end
# this one fails
it 'should have one requirement when accessed via first' do
puts "\n\n" + @p1.requirements.all.pretty_inspect + "\n"
@p1.requirements.first.description.should == 'be the best'
puts "\n\n" + @p1.requirements.all.pretty_inspect + "\n"
@p1.requirements.all.size.should == 1 # <-----------------
fails here
end
[#<Requirement @id=1 @name="Quality" @description="be the best">]
~ (0.000054) SELECT "requirements"."id", "requirements"."name" FROM
"requirements" INNER JOIN "project_requirements" ON
"requirements"."id" = "project_requirements"."requirement_id" INNER
JOIN "projects" ON "project_requirements"."project_id" =
"projects"."id" WHERE "project_requirements"."project_id" = 1 GROUP BY
"requirements"."id", "requirements"."name" ORDER BY
"requirements"."id" LIMIT 1
~ (0.000022) SELECT "id", "description" FROM "requirements" WHERE
"id" = 1 ORDER BY "id"
~ (0.000050) SELECT "requirements"."id", "requirements"."name" FROM
"requirements" INNER JOIN "project_requirements" ON
"requirements"."id" = "project_requirements"."requirement_id" INNER
JOIN "projects" ON "project_requirements"."project_id" =
"projects"."id" WHERE "project_requirements"."project_id" = 1 GROUP BY
"requirements"."id", "requirements"."name" ORDER BY
"requirements"."id"
[#<Requirement @id=1 @name="Quality" @description="be the best">,
#<Requirement @id=1 @name="Quality" @description="be the best">]
Here the full rspec example: http://gist.github.com/1260479
Any hint on what I'm doing wrong?
TIA,
Roy
--
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.