aboutsummaryrefslogtreecommitdiffstats
path: root/RAILS_VERSION
diff options
context:
space:
mode:
authorJared Armstrong and Neeraj Singh <neerajdotname@gmail.com>2013-04-10 08:34:47 -0400
committerNeeraj Singh <neerajdotname@gmail.com>2013-04-10 12:19:47 -0400
commitdc764fcc348d562376add26ff8ef5173946b575b (patch)
tree3014a67245025f0a5b46a19eeca2fca10a3dee65 /RAILS_VERSION
parentbb61d2defab7017807c310ac221c9e69d7f99d96 (diff)
downloadrails-dc764fcc348d562376add26ff8ef5173946b575b.tar.gz
rails-dc764fcc348d562376add26ff8ef5173946b575b.tar.bz2
rails-dc764fcc348d562376add26ff8ef5173946b575b.zip
While merging relations preserve context for joins
Fixes #3002. Also see #5494. ``` class Comment < ActiveRecord::Base belongs_to :post end class Author < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :author has_many :comments end ``` `Comment.joins(:post).merge(Post.joins(:author).merge(Author.where(:name => "Joe Blogs"))).all` would fail with `ActiveRecord::ConfigurationError: Association named 'author' was not found on Comment`. It is failing because `all` is being called on relation which looks like this after all the merging: `{:joins=>[:post, :author], :where=>[#<Arel::Nodes::Equality: ....}`. In this relation all the context that `Post` was joined with `Author` is lost and hence the error that `author` was not found on `Comment`. Ths solution is to build JoinAssociation when two relations with join information are being merged. And later while building the arel use the previously built `JoinAssociation` record in `JoinDependency#graft` to build the right from clause. Thanks to Jared Armstrong (https://github.com/armstrjare) for most of the work. I ported it to make it compatible with new code base.
Diffstat (limited to 'RAILS_VERSION')
0 files changed, 0 insertions, 0 deletions