Skip to content
Browse files

Fixes #10432 add_column not creating array columns in PostgreSQL

When then PostgreSQL visitor was [added](6b7fdf3)
`add_column` was no longer receiving the column options directly. This
caused the options to be lost along the way.
  • Loading branch information...
1 parent 424fa92 commit e4fe4973cf43ecd5279b376ac847181259a92678 @scudco scudco committed May 5, 2013
View
4 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.
View
1 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -269,6 +269,7 @@ def new_column_definition(name, type, options) # :nodoc:
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]
View
29 activerecord/test/cases/migration/change_schema_test.rb
@@ -74,6 +74,35 @@ def test_create_table_with_defaults
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

0 comments on commit e4fe497

Please sign in to comment.
Something went wrong with that request. Please try again.