aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
-rw-r--r--activerecord/test/cases/primary_keys_test.rb29
2 files changed, 2 insertions, 35 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 2d0eef6c84..88b09e7999 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -359,12 +359,8 @@ module ActiveRecord
# a record (as primary keys cannot be +nil+). This might be done via the
# +SecureRandom.uuid+ method and a +before_save+ callback, for instance.
def primary_key(name, type = :primary_key, options = {})
- return super unless type = :primary_key
-
- if type == :uuid
- options[:default] = options.fetch(:default, 'uuid_generate_v4()')
- end
-
+ return super unless type == :uuid
+ options[:default] = options.fetch(:default, 'uuid_generate_v4()')
options[:primary_key] = true
column name, type, options
end
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb
index a1149e410b..8e5379cb1f 100644
--- a/activerecord/test/cases/primary_keys_test.rb
+++ b/activerecord/test/cases/primary_keys_test.rb
@@ -216,32 +216,3 @@ if current_adapter?(:MysqlAdapter, :Mysql2Adapter)
end
end
-if current_adapter?(:PostgreSQLAdapter)
- class PrimaryKeyBigSerialTest < ActiveRecord::TestCase
- self.use_transactional_fixtures = false
-
- class Widget < ActiveRecord::Base
- end
-
- def setup
- @con = ActiveRecord::Base.connection
-
- ActiveRecord::Schema.define do
- create_table :widgets, id: :bigserial do |t|
- end
- end
- end
-
- def teardown
- ActiveRecord::Schema.define do
- drop_table :widgets
- end
- end
-
- def test_bigserial_primary_key
- widget = Widget.create!
-
- assert_not_nil widget.id
- end
- end
-end