diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-06-05 01:58:08 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-06-05 01:58:08 -0700 |
commit | 9d728cd70810eed775c77446d9a3bccc1081d3cd (patch) | |
tree | 853c63186df4d92b5c7650779d93745a5ceb0e44 | |
parent | 3970432fcb6a04e6f003e8295e9b2ee8e5b22390 (diff) | |
parent | e4fe4973cf43ecd5279b376ac847181259a92678 (diff) | |
download | rails-9d728cd70810eed775c77446d9a3bccc1081d3cd.tar.gz rails-9d728cd70810eed775c77446d9a3bccc1081d3cd.tar.bz2 rails-9d728cd70810eed775c77446d9a3bccc1081d3cd.zip |
Merge pull request #10482 from scudco/10432-fix-add-column-with-array
Fixes #10432 add_column not creating array columns in PostgreSQL
-rw-r--r-- | activerecord/CHANGELOG.md | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 1 | ||||
-rw-r--r-- | activerecord/test/cases/migration/change_schema_test.rb | 29 |
3 files changed, 34 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 5f63b6d7ae..e5312d7d7c 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,7 @@ +* Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432 + + *Adam Anderson* + * Usage of `implicit_readonly` is being removed`. Please use `readonly` method explicitly to mark records as `readonly. Fixes #10615. diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index aabedf15e9..c982d65d65 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -269,6 +269,7 @@ module ActiveRecord end column.limit = limit + column.array = options[:array] if column.respond_to?(:array) column.precision = options[:precision] column.scale = options[:scale] column.default = options[:default] diff --git a/activerecord/test/cases/migration/change_schema_test.rb b/activerecord/test/cases/migration/change_schema_test.rb index 54fff8a0f5..e37dca856d 100644 --- a/activerecord/test/cases/migration/change_schema_test.rb +++ b/activerecord/test/cases/migration/change_schema_test.rb @@ -74,6 +74,35 @@ module ActiveRecord assert_equal "hello", five.default unless mysql end + def test_add_column_with_array + if current_adapter?(:PostgreSQLAdapter) + connection.create_table :testings + connection.add_column :testings, :foo, :string, :array => true + + columns = connection.columns(:testings) + array_column = columns.detect { |c| c.name == "foo" } + + assert array_column.array + else + skip "array option only supported in PostgreSQLAdapter" + end + end + + def test_create_table_with_array_column + if current_adapter?(:PostgreSQLAdapter) + connection.create_table :testings do |t| + t.string :foo, :array => true + end + + columns = connection.columns(:testings) + array_column = columns.detect { |c| c.name == "foo" } + + assert array_column.array + else + skip "array option only supported in PostgreSQLAdapter" + end + end + def test_create_table_with_limits connection.create_table :testings do |t| t.column :foo, :string, :limit => 255 |