diff options
author | Edgars Beigarts <edgars.beigarts@makit.lv> | 2011-12-04 18:05:54 +0200 |
---|---|---|
committer | Edgars Beigarts <edgars.beigarts@makit.lv> | 2011-12-04 20:10:14 +0200 |
commit | 82ae5c40ea29eecc2c0d017ffc7c2f2a23a7e21f (patch) | |
tree | 0e335e80e1172d85b0edeae54995030cdd6258d0 /activerecord | |
parent | 91a3e92cc20b65d371dc885077ce6203cfb0c27e (diff) | |
download | rails-82ae5c40ea29eecc2c0d017ffc7c2f2a23a7e21f.tar.gz rails-82ae5c40ea29eecc2c0d017ffc7c2f2a23a7e21f.tar.bz2 rails-82ae5c40ea29eecc2c0d017ffc7c2f2a23a7e21f.zip |
Fix sequence name with abstract classes.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 9bc0023539..e326153c20 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -721,10 +721,10 @@ module ActiveRecord #:nodoc: end def sequence_name - if superclass == Base + if base_class == self @sequence_name ||= reset_sequence_name else - (@sequence_name ||= nil) || superclass.sequence_name + (@sequence_name ||= nil) || base_class.sequence_name end end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index d846eb03aa..343c8ef373 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1601,6 +1601,16 @@ class BasicsTest < ActiveRecord::TestCase end end + def test_sequence_name_with_abstract_class + ak = Class.new(ActiveRecord::Base) + ak.abstract_class = true + k = Class.new(ak) + k.table_name = "projects" + orig_name = k.sequence_name + return skip "sequences not supported by db" unless orig_name + assert_equal k.reset_sequence_name, orig_name + end + def test_count_with_join res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'" |