diff options
author | Patrick Robertson <patricksrobertson@gmail.com> | 2013-05-07 08:21:41 -0400 |
---|---|---|
committer | Patrick Robertson <patricksrobertson@gmail.com> | 2013-05-07 08:21:41 -0400 |
commit | 0e00c6b296b48e35fc3997648561f5da7295098a (patch) | |
tree | f40f192c3ba45801ed64d3736fbd866c2765c4fe /activerecord/test/cases | |
parent | 33283c98ed690b12bc2bca75276236dc907798b2 (diff) | |
download | rails-0e00c6b296b48e35fc3997648561f5da7295098a.tar.gz rails-0e00c6b296b48e35fc3997648561f5da7295098a.tar.bz2 rails-0e00c6b296b48e35fc3997648561f5da7295098a.zip |
Handle other pk types in PostgreSQL gracefully.
In #10410 it was noted that you can no longer create PK's with the
type of bigserial in PostgreSQL in 4.0.0.rc1. This is mostly
because the newer adapter is checking for column type with the
id column instead of just letting it pass through like it did
before.
Side effects:
You may just create a PK column of a type that you really don't
want to be your PK. As far as I can tell this was allowed in 3.2.X
and perhaps an exception should be raised if you try and do
something extremely dumb.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/primary_keys_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index 8e5379cb1f..a1149e410b 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -216,3 +216,32 @@ 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 |