Skip to content

Commit

Permalink
Merge pull request #5327 from kennyj/fix_explicitly_inheraitance_column
Browse files Browse the repository at this point in the history
Don't reset inheritance_column when setting explicitly.
  • Loading branch information
tenderlove committed Mar 16, 2012
2 parents e2b6751 + cdfcbc4 commit e61e0c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion activerecord/lib/active_record/model_schema.rb
Expand Up @@ -160,6 +160,7 @@ def inheritance_column
# Sets the value of inheritance_column
def inheritance_column=(value)
@inheritance_column = value.to_s
@explicit_inheritance_column = true
end

def sequence_name
Expand Down Expand Up @@ -303,7 +304,7 @@ def reset_column_information
@column_types = nil
@content_columns = nil
@dynamic_methods_hash = nil
@inheritance_column = nil
@inheritance_column = nil unless defined?(@explicit_inheritance_column) && @explicit_inheritance_column
@relation = nil
end

Expand Down
10 changes: 10 additions & 0 deletions activerecord/test/cases/base_test.rb
Expand Up @@ -1503,6 +1503,16 @@ def test_dont_clear_sequence_name_when_setting_explicitly
assert_equal before_seq, after_seq unless before_seq.blank? && after_seq.blank?
end

def test_dont_clear_inheritnce_column_when_setting_explicitly
Joke.inheritance_column = "my_type"
before_inherit = Joke.inheritance_column

Joke.reset_column_information
after_inherit = Joke.inheritance_column

assert_equal before_inherit, after_inherit unless before_inherit.blank? && after_inherit.blank?
end

def test_set_table_name_symbol_converted_to_string
Joke.table_name = :cold_jokes
assert_equal 'cold_jokes', Joke.table_name
Expand Down

0 comments on commit e61e0c0

Please sign in to comment.