Permalink
Browse files

Merge pull request #10482 from scudco/10432-fix-add-column-with-array

Fixes #10432 add_column not creating array columns in PostgreSQL
Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information...
1 parent 1e1b499 commit c5ba896387a39210c881076234858615fb01ff9c @tenderlove tenderlove committed Jun 5, 2013
@@ -1,4 +1,8 @@
## unreleased ##
+* Fix `add_column` with `array` option when using PostgreSQL. Fixes #10432
+
+ *Adam Anderson*
+
* Fix pending migrations error when loading schema and `ActiveRecord::Base.table_name_prefix`
is not blank.
@@ -270,6 +270,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]
@@ -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 c5ba896

Please sign in to comment.