diff options
author | Dmitry Lavrov <lavrovdv@gmail.com> | 2014-03-27 15:29:20 +0300 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-04-03 10:41:24 +0200 |
commit | 1f432c54658cf54608a6e37b70b8dc8e40521502 (patch) | |
tree | 9b43637c7d4844ecc25c039e250e9b7ceb8c1e41 /activerecord/lib | |
parent | 79f06a91345a301e1a2f2378552b5860a493b256 (diff) | |
download | rails-1f432c54658cf54608a6e37b70b8dc8e40521502.tar.gz rails-1f432c54658cf54608a6e37b70b8dc8e40521502.tar.bz2 rails-1f432c54658cf54608a6e37b70b8dc8e40521502.zip |
Treat blank UUID values as nil
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/oid.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb index 57bdc3bb19..9e898015a6 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb @@ -330,6 +330,13 @@ This is not reliable and will be removed in the future. end end + class Uuid < Type + def type; :uuid end + def type_cast(value) + value.presence + end + end + class TypeMap def initialize @mapping = {} @@ -418,10 +425,10 @@ This is not reliable and will be removed in the future. register_type 'json', OID::Json.new register_type 'cidr', OID::Cidr.new register_type 'inet', OID::Inet.new + register_type 'uuid', OID::Uuid.new register_type 'xml', SpecializedString.new(:xml) register_type 'tsvector', SpecializedString.new(:tsvector) register_type 'macaddr', SpecializedString.new(:macaddr) - register_type 'uuid', SpecializedString.new(:uuid) register_type 'citext', SpecializedString.new(:citext) register_type 'ltree', SpecializedString.new(:ltree) |