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/lib | |
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/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb index 3de794f797..25961a9869 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb @@ -45,6 +45,11 @@ module ActiveRecord delimiter == other.delimiter end + def type_cast_for_schema(value) + return super unless value.is_a?(::Array) + "[" + value.map { |v| subtype.type_cast_for_schema(v) }.join(", ") + "]" + end + private def type_cast_array(value, method) |