Ticket #8267: multiple_table_references_on_cascaded_eager_loading_fix.diff
| File multiple_table_references_on_cascaded_eager_loading_fix.diff, 3.7 kB (added by mattwestcott, 2 years ago) |
|---|
-
activerecord/test/associations/join_model_test.rb
old new 483 483 def test_has_many_through_has_many_with_sti 484 484 assert_equal [comments(:does_it_hurt)], authors(:david).special_post_comments 485 485 end 486 487 def test_multiple_table_references_on_cascaded_eager_loading 488 assert_equal comments(:greetings), authors(:david).comments_with_cited_posts.find(:all, :order => 'comments.id').first 489 end 486 490 487 491 private 488 492 # create dynamic Post models to allow different dependency options -
activerecord/test/fixtures/comment.rb
old new 1 1 class Comment < ActiveRecord::Base 2 2 belongs_to :post 3 has_many :post_citations 3 4 4 5 def self.what_are_you 5 6 'a comment...' … … 20 21 def self.what_are_you 21 22 'a very special comment...' 22 23 end 24 end 25 26 class PostCitation < ActiveRecord::Base 27 belongs_to :comment 28 belongs_to :post 23 29 end -
activerecord/test/fixtures/db_definitions/schema.rb
old new 39 39 t.column :author_id, :integer 40 40 t.column :favorite_author_id, :integer 41 41 end 42 43 create_table :post_citations, :force => true do |t| 44 t.column :comment_id, :integer 45 t.column :post_id, :integer 46 end 42 47 43 48 create_table :vertices, :force => true do |t| 44 49 t.column :label, :string -
activerecord/test/fixtures/post.rb
old new 12 12 find(:first, :order => "id DESC") 13 13 end 14 14 end 15 16 has_many :comments_with_cited_posts, :class_name => "Comment", :include => {:post_citations => :post} 15 17 16 18 has_one :very_special_comment 17 19 has_one :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post -
activerecord/test/fixtures/author.rb
old new 16 16 end 17 17 has_many :comments, :through => :posts 18 18 has_many :funky_comments, :through => :posts, :source => :comments 19 has_many :comments_with_cited_posts, :through => :posts 19 20 20 21 has_many :special_posts 21 22 has_many :special_post_comments, :through => :special_posts, :source => :comments -
activerecord/lib/active_record/associations.rb
old new 1527 1527 @aliased_table_name = table_name #.tr('.', '_') # start with the table name, sub out any .'s 1528 1528 @parent_table_name = parent.active_record.table_name 1529 1529 1530 if ! parent.table_joins.blank? && parent.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{aliased_table_name.downcase}\son}1530 if !join_dependency.join_base.table_joins.blank? && join_dependency.join_base.table_joins.to_s.downcase =~ %r{join(\s+\w+)?\s+#{aliased_table_name.downcase}\son} 1531 1531 join_dependency.table_aliases[aliased_table_name] += 1 1532 1532 end 1533 1533