diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-26 18:14:16 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-26 18:15:09 +0100 |
commit | b3407c86cfccd2cc6258b8879e91600fe25c6e48 (patch) | |
tree | 0dce9206faba6e2df06245850b0bf46c96bca56c /activerecord/lib | |
parent | e97b6f2ef747f013f8d71d7d97dc88acc673ee6d (diff) | |
download | rails-b3407c86cfccd2cc6258b8879e91600fe25c6e48.tar.gz rails-b3407c86cfccd2cc6258b8879e91600fe25c6e48.tar.bz2 rails-b3407c86cfccd2cc6258b8879e91600fe25c6e48.zip |
Don't require a DB connection when setting primary key.
Closes #2807.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/primary_key.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/base.rb | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index ed71b5e7d4..a404a5edd7 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -66,7 +66,6 @@ module ActiveRecord @primary_key ||= '' self.original_primary_key = @primary_key value &&= value.to_s - connection_pool.primary_keys[table_name] = value self.primary_key = block_given? ? instance_eval(&block) : value end end diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 558b341c06..78159d13d4 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -707,6 +707,10 @@ module ActiveRecord #:nodoc: # Returns an array of column objects for the table associated with this class. def columns + if defined?(@primary_key) + connection_pool.primary_keys[table_name] ||= primary_key + end + connection_pool.columns[table_name] end |