diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-01 16:22:34 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-01 16:22:34 -0700 |
commit | 09ac1776abc0d3482f491f2d49f47bcb3d9a4ad7 (patch) | |
tree | ed96463fab671c1543656c5b23243d9c04f35412 /activerecord/test | |
parent | d1f857e745ca38005f759a270e2affaddb8cd90d (diff) | |
parent | 55c40c0ecec50936c439548b440216c62aa4ccbb (diff) | |
download | rails-09ac1776abc0d3482f491f2d49f47bcb3d9a4ad7.tar.gz rails-09ac1776abc0d3482f491f2d49f47bcb3d9a4ad7.tar.bz2 rails-09ac1776abc0d3482f491f2d49f47bcb3d9a4ad7.zip |
Merge pull request #10404 from chadmoone/fix-pg-uuid-default
Allow override of PostgreSQL UUID primary key default
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/uuid_test.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/uuid_test.rb b/activerecord/test/cases/adapters/postgresql/uuid_test.rb index c0c0e8898c..edf18cb7a7 100644 --- a/activerecord/test/cases/adapters/postgresql/uuid_test.rb +++ b/activerecord/test/cases/adapters/postgresql/uuid_test.rb @@ -51,3 +51,34 @@ class PostgresqlUUIDTest < ActiveRecord::TestCase assert_not_nil u.other_uuid end end + +class PostgresqlUUIDTestNilDefault < ActiveRecord::TestCase + class UUID < ActiveRecord::Base + self.table_name = 'pg_uuids' + end + + def setup + @connection = ActiveRecord::Base.connection + + @connection.reconnect! + + @connection.transaction do + @connection.create_table('pg_uuids', id: false) do |t| + t.primary_key :id, :uuid, default: nil + t.string 'name' + end + end + end + + def teardown + @connection.execute 'drop table if exists pg_uuids' + end + + def test_id_allows_default_override_via_nil + col_desc = @connection.execute("SELECT pg_get_expr(d.adbin, d.adrelid) as default + FROM pg_attribute a + LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum + WHERE a.attname='id' AND a.attrelid = 'pg_uuids'::regclass").first + assert_nil col_desc["default"] + end +end |