This project is archived and is in readonly mode.
has_one :through preload drops conditions
-
Will Bryant
- Assigned user set to Frederick Cheung
Here's a test case showing the problem.
Frederick, it looks to me like in the case where there are conditions on the source table, we can't do the loading in two separate steps, we'd have to use a single query. Would it be better to always use a single query for the join table and the source table parts?
-
Frederick Cheung
That's certainly true. Something that has been on my todo list for ages has been to rewrite preload of has many/one through to not do it in two steps. I don't think it's difficult, just a little fiddly generating the join statements if you want to cover all of the various cases (and I'd like to do it without too much code duplication between this and the old style include and the normal load of hmt)
-
Will Bryant
Hi Frederick,
is this something we're working on for the 2-3-stable series, or do you plan to leave it till Rails 3.0?
-
Frederick Cheung
Ideally I would have worked on this a while ago but haven't had much time to give to rails over the past 3 months. It looks like there has been some refactoring of has many/one through so that generating the correct join clauses is less fiddly / error prone.
-
Will Bryant
- Tag changed from 2.3.3, :include, activerecord, bug, has_one, preload, through to 3.0, :include, activerecord, bug, has_one, preload, through
Just to confirm, this test is still failing in master, so broken for 3.0.
-
Jon Leighton
- Assigned user changed from Frederick Cheung to Aaron Patterson
- Tag changed from 3.0, :include, activerecord, bug, has_one, preload, through to 3.0, :include, activerecord, bug, has_one, patch, preload, through
- Importance changed from to
Here is an updated version of Will's test which applies cleanly to current master (the previous version did not). I have run it and can confirm that it passes, so this ticket can be closed. (I've edited the commit message to be more relevant to the current situation.)
-
Repository
- State changed from new to resolved
(from [c6db37e69b1ff07f7ad535d4752d0e6eb2d15bff]) Don't allow a has_one association to go :through a collection association [#2976 state:resolved] https://github.com/rails/rails/commit/c6db37e69b1ff07f7ad535d4752d0...
-
Repository
(from [b79823832e6cd30a9f14f97ffdf1642d4d63d4ea]) Verify that has_one :through preload respects the :conditions [#2976 state:resolved] https://github.com/rails/rails/commit/b79823832e6cd30a9f14f97ffdf16...
-
ssupreme11
Its my first time to visit this site and as I was exploring I cant believe that this site was made up of a very informative articles that you should try to have compliment with so as what I am doing now I really love to look forward with more interesting information on this site.. Affordable Dissertation
-
Kira Steels
Interesting. Love the codes. write my paper
