diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-08-07 18:21:45 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-08-07 20:28:14 +0200 |
commit | 806bc2add8a0807ca45fb0945856bec89a321fc8 (patch) | |
tree | 110f833ad13c44202fceffe25233e2e2b343e80b /activerecord/lib/active_record/connection_adapters | |
parent | 4343e2dda25222d3586835bb25009e1a490cda8f (diff) | |
download | rails-806bc2add8a0807ca45fb0945856bec89a321fc8.tar.gz rails-806bc2add8a0807ca45fb0945856bec89a321fc8.tar.bz2 rails-806bc2add8a0807ca45fb0945856bec89a321fc8.zip |
Fix multidimensional PG arrays containing non-string items
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/cast.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index a73f0ac57f..56dc9ea813 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -115,7 +115,7 @@ module ActiveRecord end def string_to_array(string, oid) - parse_pg_array(string).map{|val| oid.type_cast val} + parse_pg_array(string).map {|val| type_cast_array(oid, val)} end private @@ -146,6 +146,14 @@ module ActiveRecord "\"#{value.gsub(/"/,"\\\"")}\"" end end + + def type_cast_array(oid, value) + if ::Array === value + value.map {|item| type_cast_array(oid, item)} + else + oid.type_cast value + end + end end end end |