class PostgresqlCompositeTest
Composites are mapped to `OID::Identity` by default. The user is informed by a warning like:
"unknown OID 5653508: failed to recognize type of 'address'. It will be treated as String."
To take full advantage of composite types, we suggest you register your own OID::Type
. See PostgresqlCompositeWithCustomOIDTest
Public Instance Methods
test_column()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/composite_test.rb, line 48 def test_column ensure_warning_is_issued column = PostgresqlComposite.columns_hash["address"] assert_nil column.type assert_equal "full_address", column.sql_type assert_not column.array? type = PostgresqlComposite.type_for_attribute("address") assert_not type.binary? end
test_composite_mapping()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/composite_test.rb, line 60 def test_composite_mapping ensure_warning_is_issued @connection.execute "INSERT INTO postgresql_composites VALUES (1, ROW('Paris', 'Champs-Élysées'));" composite = PostgresqlComposite.first assert_equal "(Paris,Champs-Élysées)", composite.address composite.address = "(Paris,Rue Basse)" composite.save! assert_equal '(Paris,"Rue Basse")', composite.reload.address end
Private Instance Methods
ensure_warning_is_issued()
click to toggle source
# File activerecord/test/cases/adapters/postgresql/composite_test.rb, line 74 def ensure_warning_is_issued warning = capture(:stderr) do PostgresqlComposite.columns_hash end assert_match(/unknown OID \d+: failed to recognize type of 'address'\. It will be treated as String\./, warning) end