From 200d994870e0b2e59c31ab9d268def19abc563cf Mon Sep 17 00:00:00 2001 From: kennyj Date: Sun, 4 Mar 2012 22:18:57 +0900 Subject: Don't clear sequence name when we explicitly assign it. --- activerecord/lib/active_record/model_schema.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 8710884bfd..73c9e22aa3 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -123,7 +123,7 @@ module ActiveRecord @table_name = value @quoted_table_name = nil @arel_table = nil - @sequence_name = nil + @sequence_name = nil unless defined?(@explicitly_sequence_name) && @explicitly_sequence_name @relation = Relation.new(self, arel_table) end @@ -170,7 +170,8 @@ module ActiveRecord end def reset_sequence_name #:nodoc: - self.sequence_name = connection.default_sequence_name(table_name, primary_key) + @sequence_name = connection.default_sequence_name(table_name, primary_key) + @explicitly_sequence_name = false end # Sets the name of the sequence to use when generating ids to the given @@ -189,6 +190,7 @@ module ActiveRecord # end def sequence_name=(value) @sequence_name = value.to_s + @explicitly_sequence_name = true end # Indicates whether the table associated with this class exists -- cgit v1.2.3