class PostgresqlUUIDGenerationTest
Public Instance Methods
migrate(x)
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 262 def migrate(x) create_table("pg_uuids_4", id: :uuid) end
test_auto_create_uuid()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 223 def test_auto_create_uuid u = UUID.create u.reload assert_not_nil u.other_uuid end
test_id_has_a_default()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 218 def test_id_has_a_default u = UUID.create assert_not_nil u.id end
test_id_is_uuid()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 213 def test_id_is_uuid assert_equal :uuid, UUID.columns_hash["id"].type assert UUID.primary_key end
test_pk_and_sequence_for_uuid_primary_key()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 229 def test_pk_and_sequence_for_uuid_primary_key pk, seq = connection.pk_and_sequence_for("pg_uuids") assert_equal "id", pk assert_nil seq end
test_schema_dumper_for_uuid_primary_key()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 235 def test_schema_dumper_for_uuid_primary_key schema = dump_table_schema "pg_uuids" assert_match(/\bcreate_table "pg_uuids", id: :uuid, default: -> { "uuid_generate_v1\(\)" }/, schema) assert_match(/t\.uuid "other_uuid", default: -> { "uuid_generate_v4\(\)" }/, schema) end
test_schema_dumper_for_uuid_primary_key_default()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 247 def test_schema_dumper_for_uuid_primary_key_default schema = dump_table_schema "pg_uuids_3" if connection.supports_pgcrypto_uuid? assert_match(/\bcreate_table "pg_uuids_3", id: :uuid, default: -> { "gen_random_uuid\(\)" }/, schema) else assert_match(/\bcreate_table "pg_uuids_3", id: :uuid, default: -> { "uuid_generate_v4\(\)" }/, schema) end end
test_schema_dumper_for_uuid_primary_key_default_in_legacy_migration()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 256 def test_schema_dumper_for_uuid_primary_key_default_in_legacy_migration @verbose_was = ActiveRecord::Migration.verbose ActiveRecord::Migration.verbose = false migration = Class.new(ActiveRecord::Migration[5.0]) do def version; 101 end def migrate(x) create_table("pg_uuids_4", id: :uuid) end end.new ActiveRecord::Migrator.new(:up, [migration]).migrate schema = dump_table_schema "pg_uuids_4" assert_match(/\bcreate_table "pg_uuids_4", id: :uuid, default: -> { "uuid_generate_v4\(\)" }/, schema) ensure drop_table "pg_uuids_4" ActiveRecord::Migration.verbose = @verbose_was end
test_schema_dumper_for_uuid_primary_key_with_custom_default()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 241 def test_schema_dumper_for_uuid_primary_key_with_custom_default schema = dump_table_schema "pg_uuids_2" assert_match(/\bcreate_table "pg_uuids_2", id: :uuid, default: -> { "my_uuid_generator\(\)" }/, schema) assert_match(/t\.uuid "other_uuid_2", default: -> { "my_uuid_generator\(\)" }/, schema) end
version()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/uuid_test.rb, line 261 def version; 101 end