diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-06-11 16:48:23 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-06-11 16:50:25 -0600 |
commit | 5b35562d8e8f7270c75e83645498dd92a0968072 (patch) | |
tree | 4070f6f997d38dc3002e2190ae40661880dd8963 /activerecord/test | |
parent | 21f7bcbaa7709ed072bb2e1273d25c09eeaa26d9 (diff) | |
download | rails-5b35562d8e8f7270c75e83645498dd92a0968072.tar.gz rails-5b35562d8e8f7270c75e83645498dd92a0968072.tar.bz2 rails-5b35562d8e8f7270c75e83645498dd92a0968072.zip |
Correctly handle array columns with defaults in the schema dumper
If the subtype provides custom schema dumping behavior, we need to defer
to it. We purposely choose not to handle any values other than an array
(which technically should only ever be `nil`, but I'd rather code
defensively here).
Fixes #20515.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/schema_dumper_test.rb | 5 | ||||
-rw-r--r-- | activerecord/test/schema/postgresql_specific_schema.rb | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb index e6f0fe6f75..51170c533b 100644 --- a/activerecord/test/cases/schema_dumper_test.rb +++ b/activerecord/test/cases/schema_dumper_test.rb @@ -253,6 +253,11 @@ class SchemaDumperTest < ActiveRecord::TestCase assert_match %r{t\.integer\s+"big_int_data_points\",\s+limit: 8,\s+array: true}, output end + def test_schema_dump_allows_array_of_decimal_defaults + output = standard_dump + assert_match %r{t\.decimal\s+"decimal_array_default",\s+default: \[1.23, 3.45\],\s+array: true}, output + end + if ActiveRecord::Base.connection.supports_extensions? def test_schema_dump_includes_extensions connection = ActiveRecord::Base.connection diff --git a/activerecord/test/schema/postgresql_specific_schema.rb b/activerecord/test/schema/postgresql_specific_schema.rb index 872fa595b4..df0362573b 100644 --- a/activerecord/test/schema/postgresql_specific_schema.rb +++ b/activerecord/test/schema/postgresql_specific_schema.rb @@ -107,5 +107,6 @@ _SQL create_table :bigint_array, force: true do |t| t.integer :big_int_data_points, limit: 8, array: true + t.decimal :decimal_array_default, array: true, default: [1.23, 3.45] end end |