This project is archived and is in readonly mode.
Better query for ASSOCIATION_ids
-
Emilio Tagua
- Tag changed from activerecord, eager_loading, enhancement, has_many, joins to activerecord, eager_loading, enhancement, has_many, joins, patch
I attach the patch that does this, selecting only ids when the association hasn't been loaded, but in case you have already loaded the records, just map the ids has done before and prevent Rails of doing an extra query.
I also removed trailing whitespaces in the test file.
-
Jeremy Kemper
- State changed from new to open
- Assigned user set to Jeremy Kemper
- Milestone cleared.
The test covers has_many only, but the change affects habtm and has_many :through also.
-
Emilio Tagua
Added the tests for has_many :through and has_and_belongs_to_many.
-
Bertg
This patch will fail if an other column is defined as the id column.
The 'self.class.primary_key' property should be used...
-
Jeremy Kemper
First patch was applied in http://github.com/rails/rails/co...
Could you rebase the fix against master?
-
Emilio Tagua
Bertg, you are right i missed that, i attach the patch that applies on top of the first one, since it is already applied, and fix the reported issue.
-
Repository
- State changed from open to resolved
(from [6183e55f714b436335dc843528be7525c342d922]) Use reflection primary_key instead of id for when selecting association ids.
[#906 Better query for ASSOCIATION_ids state:resolved]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net http://github.com/rails/rails/co...
