aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-05-15 18:53:47 +0100
committerPratik Naik <pratiknaik@gmail.com>2010-05-15 18:53:47 +0100
commit47c9a355062888feb2c7ea7c794e914a9b78f50c (patch)
treeb9aab486b7fb4bde85f503fb2e2e4d52fac8731d /activerecord
parentfa99de0bd054576336c940ca78f3d1b35b6e490e (diff)
downloadrails-47c9a355062888feb2c7ea7c794e914a9b78f50c.tar.gz
rails-47c9a355062888feb2c7ea7c794e914a9b78f50c.tar.bz2
rails-47c9a355062888feb2c7ea7c794e914a9b78f50c.zip
Reset quoted_table_name after set_table_name [#4568 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb2
-rwxr-xr-xactiverecord/test/cases/base_test.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index e7319ce8b9..04c474c9a1 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -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
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index bbc4e543d5..b7ae619787 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -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" }