Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Find() on an association with an inverse will now scan existing in-memory records #9529

Merged
merged 1 commit into from Mar 19, 2013

Conversation

Projects
None yet
2 participants
Contributor

wangjohn commented Mar 3, 2013

The problem in #9470 is that when a user defines :inverse_of in an association, the find() method does not check the records that are already loaded in the association, but will instead go to the database directly.

I've changed this so that when a user calls find() on an association which has an :inverse_of flag, then the find_by_scan() method is called, which basically does a scan over the loaded_target (which includes all current children, including new and existing records).

@wangjohn wangjohn Calling find() on an association with an inverse will now check to see
if the association already holds that record in memory before checking
the database for the specified ids.
840ca09

@jeremy jeremy added a commit that referenced this pull request Mar 19, 2013

@jeremy jeremy Merge pull request #9529 from wangjohn/find_on_inverse_of_bugfix_9470
Find() on an association with an inverse will now scan existing in-memory records
0fe4ae9

@jeremy jeremy merged commit 0fe4ae9 into rails:master Mar 19, 2013

@wangjohn wangjohn deleted the wangjohn:find_on_inverse_of_bugfix_9470 branch Mar 19, 2013

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