diff options
author | kennyj <kennyj@gmail.com> | 2012-03-03 20:32:46 +0900 |
---|---|---|
committer | kennyj <kennyj@gmail.com> | 2012-03-04 22:22:27 +0900 |
commit | 640f6c201d59cd7fc16943154372d4ef754f33f4 (patch) | |
tree | 78409fdc5bc9fc118d50e2742648f36227caeab4 /activerecord/lib/active_record | |
parent | 223549f420583e8cfaa280542da679d6c6045b44 (diff) | |
download | rails-640f6c201d59cd7fc16943154372d4ef754f33f4.tar.gz rails-640f6c201d59cd7fc16943154372d4ef754f33f4.tar.bz2 rails-640f6c201d59cd7fc16943154372d4ef754f33f4.zip |
Fix GH #4674. Reset column information and sequence name when setting table_name.
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 60bac2f802..8710884bfd 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -114,10 +114,17 @@ module ActiveRecord # You can also just define your own <tt>self.table_name</tt> method; see # the documentation for ActiveRecord::Base#table_name. def table_name=(value) - @table_name = value && value.to_s - @quoted_table_name = nil - @arel_table = nil - @relation = Relation.new(self, arel_table) + value = value && value.to_s + if defined?(@table_name) + return if value == @table_name + + reset_column_information + end + @table_name = value + @quoted_table_name = nil + @arel_table = nil + @sequence_name = nil + @relation = Relation.new(self, arel_table) end # Returns a quoted version of the table name, used to construct SQL statements. |