diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-15 17:33:22 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-10-15 17:33:22 -0700 |
commit | 66cd96d0e99051dfed08dbedd561f298f9e37c18 (patch) | |
tree | 5915bddf54330caf01637255fadf039feb56d434 /activerecord | |
parent | 574234be067f0f000a945560cabcabb68c8a1ec9 (diff) | |
download | rails-66cd96d0e99051dfed08dbedd561f298f9e37c18.tar.gz rails-66cd96d0e99051dfed08dbedd561f298f9e37c18.tar.bz2 rails-66cd96d0e99051dfed08dbedd561f298f9e37c18.zip |
just look up the primary key from the columns hash
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index fca5cd2efa..03ab48784a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -256,7 +256,7 @@ module ActiveRecord name = name.to_s type = type.to_sym - if primary_key_column_name == name + if @columns_hash[name] && @columns_hash[name].primary_key? raise ArgumentError, "you can't redefine the primary key column '#{name}'. To define a custom primary key, pass { id: false } to create_table." end @@ -340,11 +340,6 @@ module ActiveRecord ColumnDefinition.new name, type end - def primary_key_column_name - primary_key_column = columns.detect { |c| c.primary_key? } - primary_key_column && primary_key_column.name - end - def native @native end |