diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-17 11:00:06 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-17 11:00:06 -0800 |
commit | cc74088c6cd4da7d3ce7bc0d66c4cae509693622 (patch) | |
tree | bd96188f25c7149155294c87316b3c90bcdc59d9 /activerecord/lib/active_record/connection_adapters/postgresql/oid.rb | |
parent | 75ba92e993d13bf3dffa56f06a72f07dad44b4a6 (diff) | |
parent | 9a4a095ed7ea6f0f65cc9e3bf3258cbdd0ddc210 (diff) | |
download | rails-cc74088c6cd4da7d3ce7bc0d66c4cae509693622.tar.gz rails-cc74088c6cd4da7d3ce7bc0d66c4cae509693622.tar.bz2 rails-cc74088c6cd4da7d3ce7bc0d66c4cae509693622.zip |
Merge pull request #8528 from le0pard/fixed_ar_intrange
AR supporting new int4range and int8range data type on PostgreSQL >= 9.2
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb index 52344f61c0..18ea83ce42 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb @@ -168,6 +168,14 @@ module ActiveRecord end end + class IntRange < Type + def type_cast(value) + return if value.nil? + + ConnectionAdapters::PostgreSQLColumn.string_to_intrange value + end + end + class TypeMap def initialize @mapping = {} @@ -269,6 +277,9 @@ module ActiveRecord register_type 'hstore', OID::Hstore.new register_type 'json', OID::Json.new + register_type 'int4range', OID::IntRange.new + alias_type 'int8range', 'int4range' + register_type 'cidr', OID::Cidr.new alias_type 'inet', 'cidr' end |