Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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

wangjohn
Copy link
Contributor

@wangjohn 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).

if the association already holds that record in memory before checking
the database for the specified ids.
jeremy added a commit that referenced this pull request Mar 19, 2013
Find() on an association with an inverse will now scan existing in-memory records
@jeremy jeremy merged commit 0fe4ae9 into rails:master Mar 19, 2013
@wangjohn wangjohn deleted the find_on_inverse_of_bugfix_9470 branch March 19, 2013 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants