From 66cd96d0e99051dfed08dbedd561f298f9e37c18 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 15 Oct 2014 17:33:22 -0700 Subject: just look up the primary key from the columns hash --- .../connection_adapters/abstract/schema_definitions.rb | 7 +------ 1 file changed, 1 insertion(+), 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 -- cgit v1.2.3