Provide a fix for many associations not yielding to each in callbacks. #462

Merged
merged 1 commit into from Oct 3, 2012

2 participants

@gaffneyc

⚠️ Feedback / review wanted

Ran into an issue when iterating over a many association in a
before_save callback on a document. For an association named foos,
foos.inspect would show the items but foos.each would never yield to
the given block since it appears to be empty.

The original issue I was tracking down was that instead of not yielding
it was yielding instances of Mongo::Cursor instead of the association
object. I haven't been able to recreate that case outside of the app.

I don't know if this is the best way to fix the issue. We started seeing the above issue in our app starting at b965105.

@gaffneyc gaffneyc Provide a fix for many associations not yielding to each in callbacks.
Ran into an issue when iterating over a many association in a
before_save callback on a document. For an association named foos,
`foos.inspect` would show the items but `foos.each` would never yield to
the given block since it appears to be empty.

The original issue I was tracking down was that instead of not yielding
it was yielding instances of Mongo::Cursor instead of the association
object. I haven't been able to recreate that case.
9844b2a
@jnunemaker

I'm not a huge fan of the commit that you referenced that started the issues. Automatic is generally a bad thing and that commit moves to automatic.

Thanks for digging in. I'll pull this so at least your issue is fixed until I can whip things back into shape regarding the commit you referenced.

@jnunemaker jnunemaker merged commit d1eb6bc into master Oct 3, 2012

1 check failed

Details default The Travis build failed
@gaffneyc

I got the feeling that there is a weird boundary between MongoMapper and Plucky, that commit made me feel like Plucky knew too much about MongoMapper's implementation. Should be a cleaner division.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment