1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Reset quoted_table_name after set_table_name [#4568 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
This commit is contained in:
Santiago Pastorino 2010-05-15 18:53:47 +01:00 committed by Pratik Naik
parent fa99de0bd0
commit 47c9a35506
2 changed files with 13 additions and 1 deletions

View file

@ -668,7 +668,6 @@ module ActiveRecord #:nodoc:
name = "#{full_table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}"
end
@quoted_table_name = nil
set_table_name(name)
name
end
@ -702,6 +701,7 @@ module ActiveRecord #:nodoc:
# set_table_name "project"
# end
def set_table_name(value = nil, &block)
@quoted_table_name = nil
define_attr_method :table_name, value, &block
end
alias :table_name= :set_table_name

View file

@ -1793,6 +1793,18 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal "bar", k.table_name
end
def test_quoted_table_name_after_set_table_name
klass = Class.new(ActiveRecord::Base)
klass.set_table_name "foo"
assert_equal "foo", klass.table_name
assert_equal klass.connection.quote_table_name("foo"), klass.quoted_table_name
klass.set_table_name "bar"
assert_equal "bar", klass.table_name
assert_equal klass.connection.quote_table_name("bar"), klass.quoted_table_name
end
def test_set_table_name_with_block
k = Class.new( ActiveRecord::Base )
k.set_table_name { "ks" }