Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7940

Show
Ignore:
Timestamp:
10/16/07 06:56:07 (11 months ago)
Author:
bitsweat
Message:

Fix regression where the association would not construct new finder SQL on save causing bogus queries for "WHERE owner_id = NULL" even after owner was saved. References #8713.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/activerecord/CHANGELOG

    r7844 r7940  
     1*SVN* 
     2 
     3* Fix regression where the association would not construct new finder SQL on save causing bogus queries for "WHERE owner_id = NULL" even after owner was saved.  #8713 [Bryan Helmkamp] 
     4 
     5 
    16*1.15.5* (October 12th, 2007) 
    27 
  • branches/1-2-stable/activerecord/lib/active_record/associations.rb

    r7823 r7940  
    10031003            end 
    10041004 
    1005             if !records_to_save.blank? 
    1006               records_to_save.each { |record| association.send(:insert_record, record) } 
    1007               association.send(:construct_sql)   # reconstruct the SQL queries now that we know the owner's id 
    1008             end 
     1005            records_to_save.each { |record| association.send(:insert_record, record) } unless records_to_save.blank? 
     1006             
     1007            # reconstruct the SQL queries now that we know the owner's id 
     1008            association.send(:construct_sql) if association.respond_to?(:construct_sql) 
    10091009          end_eval 
    10101010 
  • branches/1-2-stable/activerecord/test/associations_test.rb

    r7823 r7940  
    1111require 'fixtures/post' 
    1212require 'fixtures/author' 
     13require 'fixtures/person' 
     14require 'fixtures/reader' 
    1315 
    1416 
     
    2123      Class.new(ActiveRecord::Base).has_many(:wheels, :name => 'wheels') 
    2224    end 
     25  end 
     26   
     27  def test_should_construct_new_finder_sql_after_create 
     28    person = Person.new 
     29    assert_equal [], person.readers.find(:all) 
     30    person.save! 
     31    reader = Reader.create! :person => person, :post => Post.new(:title => "foo", :body => "bar") 
     32    assert_equal [reader], person.readers.find(:all) 
    2333  end 
    2434