diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb | 12 |
1 files changed, 8 insertions, 4 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 87817fe8d1..4e7d472d97 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb @@ -12,12 +12,16 @@ module ActiveRecord def type_cast_from_database(value) if value.is_a?(::String) - type_cast_array(parse_pg_array(value)) + type_cast_array(parse_pg_array(value), :type_cast_from_database) else super end end + def type_cast_from_user(value) + type_cast_array(value, :type_cast_from_user) + end + # Loads pg_array_parser if available. String parsing can be # performed quicker by a native extension, which will not create # a large amount of Ruby objects that will need to be garbage @@ -32,11 +36,11 @@ module ActiveRecord private - def type_cast_array(value) + def type_cast_array(value, method) if value.is_a?(::Array) - value.map { |item| type_cast_array(item) } + value.map { |item| type_cast_array(item, method) } else - @subtype.type_cast_from_database(value) + @subtype.public_send(method, value) end end end |