Permalink
Browse files

Reset quoted_table_name after set_table_name [#4568 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent fa99de0 commit 47c9a355062888feb2c7ea7c794e914a9b78f50c @spastorino spastorino committed with lifo May 15, 2010
Showing with 13 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/base.rb
  2. +12 −0 activerecord/test/cases/base_test.rb
@@ -668,7 +668,6 @@ def reset_table_name #: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 @@ def reset_sequence_name #: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
@@ -1793,6 +1793,18 @@ def test_set_table_name_with_value
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" }

0 comments on commit 47c9a35

Please sign in to comment.