Changeset 8828
- Timestamp:
- 02/10/08 01:02:38 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/2-0-stable/activerecord/CHANGELOG
r8631 r8828 1 1 *SVN* 2 3 * Ensure that modifying has_and_belongs_to_many actions clear the query cache. Closes #10840 [john.andrews] 2 4 3 5 * Fix issue where Table#references doesn't pass a :null option to a *_type attribute for polymorphic associations. Closes #10753 [railsjitsu] branches/2-0-stable/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
r8481 r8828 15 15 create_record(attributes) { |record| insert_record(record) } 16 16 end 17 17 18 18 def create!(attributes = {}) 19 19 create_record(attributes) { |record| insert_record(record, true) } … … 81 81 82 82 if @reflection.options[:insert_sql] 83 @owner.connection. execute(interpolate_sql(@reflection.options[:insert_sql], record))83 @owner.connection.insert(interpolate_sql(@reflection.options[:insert_sql], record)) 84 84 else 85 85 columns = @owner.connection.columns(@reflection.options[:join_table], "#{@reflection.options[:join_table]} Columns") … … 104 104 "VALUES (#{attributes.values.join(', ')})" 105 105 106 @owner.connection. execute(sql)106 @owner.connection.insert(sql) 107 107 end 108 108 … … 112 112 def delete_records(records) 113 113 if sql = @reflection.options[:delete_sql] 114 records.each { |record| @owner.connection. execute(interpolate_sql(sql, record)) }114 records.each { |record| @owner.connection.delete(interpolate_sql(sql, record)) } 115 115 else 116 116 ids = quoted_record_ids(records) 117 sql = "DELETE FROM #{@ reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})"118 @owner.connection. execute(sql)117 sql = "DELETE FROM #{@owner.connection.quote_table_name @reflection.options[:join_table]} WHERE #{@reflection.primary_key_name} = #{@owner.quoted_id} AND #{@reflection.association_foreign_key} IN (#{ids})" 118 @owner.connection.delete(sql) 119 119 end 120 120 end branches/2-0-stable/activerecord/test/query_cache_test.rb
r7498 r8828 4 4 require 'fixtures/task' 5 5 require 'fixtures/course' 6 require 'fixtures/category' 7 require 'fixtures/post' 6 8 7 9 8 class QueryCacheTest < Test::Unit::TestCase9 fixtures :tasks, :topics 10 class QueryCacheTest < ActiveSupport::TestCase 11 fixtures :tasks, :topics, :categories, :posts, :categories_posts 10 12 11 13 def test_find_queries … … 100 102 end 101 103 end 104 105 def test_cache_is_expired_by_habtm_update 106 ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) 107 ActiveRecord::Base.cache do 108 c = Category.find(:first) 109 p = Post.find(:first) 110 p.categories << c 111 end 112 end 113 114 def test_cache_is_expired_by_habtm_delete 115 ActiveRecord::Base.connection.expects(:clear_query_cache).times(2) 116 ActiveRecord::Base.cache do 117 c = Category.find(:first) 118 p = Post.find(:first) 119 p.categories.delete_all 120 end 121 end 102 122 end 103 123