Changeset 8762
- Timestamp:
- 01/31/08 07:50:15 (4 months ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/association_preload.rb (modified) (2 diffs)
- trunk/activerecord/test/cases/associations/eager_test.rb (modified) (2 diffs)
- trunk/activerecord/test/fixtures/owners.yml (added)
- trunk/activerecord/test/fixtures/pets.yml (added)
- trunk/activerecord/test/models/owner.rb (added)
- trunk/activerecord/test/models/pet.rb (added)
- trunk/activerecord/test/schema/schema.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r8757 r8762 5 5 * belongs_to supports :dependent => :destroy and :delete. #10592 [Jonathan Viney] 6 6 7 * Introduce preload query strategy for eager :includes. #9640 [Frederick Cheung, Aleksey Kondratenko ]7 * Introduce preload query strategy for eager :includes. #9640 [Frederick Cheung, Aleksey Kondratenko, codafoo] 8 8 9 9 * Support aggregations in finder conditions. #10572 [Ryan Kinderman] trunk/activerecord/lib/active_record/association_preload.rb
r8672 r8762 181 181 182 182 table_name = klass.table_name 183 primary_key = klass.primary_key 183 184 conditions = "#{table_name}.#{primary_key} IN (?)" 184 185 conditions << append_conditions(options, preload_options) … … 188 189 :joins => options[:joins], 189 190 :order => options[:order]) 190 set_association_single_records(id_map, reflection.name, associated_records, 'id')191 set_association_single_records(id_map, reflection.name, associated_records, primary_key) 191 192 end 192 193 end trunk/activerecord/test/cases/associations/eager_test.rb
r8681 r8762 8 8 require 'models/person' 9 9 require 'models/reader' 10 require 'models/owner' 11 require 'models/pet' 10 12 11 13 class EagerAssociationTest < ActiveRecord::TestCase 12 14 fixtures :posts, :comments, :authors, :categories, :categories_posts, 13 :companies, :accounts, :tags, :taggings, :people, :readers 15 :companies, :accounts, :tags, :taggings, :people, :readers, 16 :owners, :pets 14 17 15 18 def test_loading_with_one_association … … 72 75 def test_loading_with_no_associations 73 76 assert_nil Post.find(posts(:authorless).id, :include => :author).author 77 end 78 79 def test_eager_association_loading_with_belongs_to_and_foreign_keys 80 pets = Pet.find(:all, :include => :owner) 81 assert_equal 3, pets.length 74 82 end 75 83 trunk/activerecord/test/schema/schema.rb
r8745 r8762 359 359 t.integer :value 360 360 end 361 362 create_table :owners, :primary_key => :owner_id ,:force => true do |t| 363 t.string :name 364 end 365 366 create_table :pets, :primary_key => :pet_id ,:force => true do |t| 367 t.string :name 368 t.integer :owner_id, :integer 369 end 361 370 end