aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-01-08 14:09:31 -0700
committerSean Griffin <sean@seantheprogrammer.com>2016-01-08 14:11:45 -0700
commit302e92359cc88258ae15a82454c58408a4b8157e (patch)
treebec6f312290020841080ccca0878fd2f2bf57fe5 /activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb
parentc1a1595740b243bed02f5e59090cc58dac77bbf3 (diff)
downloadrails-302e92359cc88258ae15a82454c58408a4b8157e.tar.gz
rails-302e92359cc88258ae15a82454c58408a4b8157e.tar.bz2
rails-302e92359cc88258ae15a82454c58408a4b8157e.zip
Refactor tz aware types, add support for PG ranges
This is an alternate implementation to #22875, that generalizes a lot of the logic that type decorators are going to need, in order to have them work with arrays, ranges, etc. The types have the ability to map over a value, with the default implementation being to just yield that given value. Array and Range give more appropriate definitions. This does not automatically make ranges time zone aware, as they need to be added to the `time_zone_aware` types config, but we could certainly make that change if we feel it is appropriate. I do think this would be a breaking change however, and should at least have a deprecation cycle. Closes #22875. /cc @matthewd
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb4
1 files changed, 4 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 25961a9869..87593ef704 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb
@@ -50,6 +50,10 @@ module ActiveRecord
"[" + value.map { |v| subtype.type_cast_for_schema(v) }.join(", ") + "]"
end
+ def map(value, &block)
+ value.map(&block)
+ end
+
private
def type_cast_array(value, method)