aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/properties.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-05-30 13:51:27 -0700
committerSean Griffin <sean@thoughtbot.com>2014-05-31 05:43:21 -0700
commit6c5763b769a977c96f68008d5b50542f7d472526 (patch)
tree46fe0816db9e9bf8f96f25bfdd7e625f6bb001df /activerecord/lib/active_record/properties.rb
parent2c51c405e0eb75a1c3acc7f1ec0da4d4ee90cb30 (diff)
downloadrails-6c5763b769a977c96f68008d5b50542f7d472526.tar.gz
rails-6c5763b769a977c96f68008d5b50542f7d472526.tar.bz2
rails-6c5763b769a977c96f68008d5b50542f7d472526.zip
Clear all caches calculated based on `@columns` when `@columns` changes
Diffstat (limited to 'activerecord/lib/active_record/properties.rb')
-rw-r--r--activerecord/lib/active_record/properties.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/properties.rb b/activerecord/lib/active_record/properties.rb
index 21ff906fec..e70f84808d 100644
--- a/activerecord/lib/active_record/properties.rb
+++ b/activerecord/lib/active_record/properties.rb
@@ -75,7 +75,7 @@ module ActiveRecord
# store_listing.price_in_cents # => 1000
def property(name, cast_type, options = {})
name = name.to_s
- clear_properties_cache
+ clear_caches_calculated_from_columns
# Assign a new hash to ensure that subclasses do not share a hash
self.user_provided_columns = user_provided_columns.merge(name => connection.new_column(name, options[:default], cast_type))
end
@@ -92,7 +92,7 @@ module ActiveRecord
def reset_column_information # :nodoc:
super
- clear_properties_cache
+ clear_caches_calculated_from_columns
end
private
@@ -108,9 +108,13 @@ module ActiveRecord
existing_columns + new_columns
end
- def clear_properties_cache
+ def clear_caches_calculated_from_columns
@columns = nil
@columns_hash = nil
+ @column_types = nil
+ @column_defaults = nil
+ @column_names = nil
+ @content_columns = nil
end
end
end