diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-02-28 10:05:13 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-02-28 13:42:30 +0100 |
commit | 5d0ca7462255b7d52a007cfe5bbc7e1bf67c3f79 (patch) | |
tree | 207ec701352d5531aafda951940d38999119e2d0 /activerecord/test/cases/adapters | |
parent | 36abb550e730ad8348e245887a7f89ea74501c8b (diff) | |
download | rails-5d0ca7462255b7d52a007cfe5bbc7e1bf67c3f79.tar.gz rails-5d0ca7462255b7d52a007cfe5bbc7e1bf67c3f79.tar.bz2 rails-5d0ca7462255b7d52a007cfe5bbc7e1bf67c3f79.zip |
Support PostgreSQL specific column types when using `change_table`.
Closes #9480.
We use `TableDefinition` for `#create_table` and `Table` for `#change_table`.
The PostgreSQL sepcifc types were only defined on `TableDefinition` so I
also added them to `Table`.
Diffstat (limited to 'activerecord/test/cases/adapters')
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/hstore_test.rb | 15 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/json_test.rb | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/activerecord/test/cases/adapters/postgresql/hstore_test.rb b/activerecord/test/cases/adapters/postgresql/hstore_test.rb index 6640f9b497..ad98d7c8ce 100644 --- a/activerecord/test/cases/adapters/postgresql/hstore_test.rb +++ b/activerecord/test/cases/adapters/postgresql/hstore_test.rb @@ -65,6 +65,21 @@ class PostgresqlHstoreTest < ActiveRecord::TestCase assert_equal :hstore, @column.type end + def test_change_table_supports_hstore + @connection.transaction do + @connection.change_table('hstores') do |t| + t.hstore 'users', default: '' + end + Hstore.reset_column_information + column = Hstore.columns.find { |c| c.name == 'users' } + assert_equal :hstore, column.type + + raise ActiveRecord::Rollback # reset the schema change + end + ensure + Hstore.reset_column_information + end + def test_type_cast_hstore assert @column diff --git a/activerecord/test/cases/adapters/postgresql/json_test.rb b/activerecord/test/cases/adapters/postgresql/json_test.rb index d64037eec0..6fc08ae4f0 100644 --- a/activerecord/test/cases/adapters/postgresql/json_test.rb +++ b/activerecord/test/cases/adapters/postgresql/json_test.rb @@ -31,6 +31,21 @@ class PostgresqlJSONTest < ActiveRecord::TestCase assert_equal :json, @column.type end + def test_change_table_supports_json + @connection.transaction do + @connection.change_table('json_data_type') do |t| + t.json 'users', default: '{}' + end + JsonDataType.reset_column_information + column = JsonDataType.columns.find { |c| c.name == 'users' } + assert_equal :json, column.type + + raise ActiveRecord::Rollback # reset the schema change + end + ensure + JsonDataType.reset_column_information + end + def test_type_cast_json assert @column |