aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/oid
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-16 15:51:47 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-16 15:51:47 -0300
commitd12b30f99700721114891c37be217a2888393feb (patch)
tree752135030892078214c8519949428e379e9fc7d3 /activerecord/lib/active_record/connection_adapters/postgresql/oid
parentdf8b021102d96e5ccadc9a633e846bb33c8466c6 (diff)
parentf378f23653259dee98061b279b628eb774e6faf1 (diff)
downloadrails-d12b30f99700721114891c37be217a2888393feb.tar.gz
rails-d12b30f99700721114891c37be217a2888393feb.tar.bz2
rails-d12b30f99700721114891c37be217a2888393feb.zip
Merge pull request #15944 from seuros/uuid
Treat invalid uuid as nil Conflicts: activerecord/CHANGELOG.md
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb
index 89728b0fe2..dd97393eac 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb
@@ -3,12 +3,21 @@ module ActiveRecord
module PostgreSQL
module OID # :nodoc:
class Uuid < Type::Value # :nodoc:
+ RFC_4122 = %r{\A\{?[a-fA-F0-9]{4}-?
+ [a-fA-F0-9]{4}-?
+ [a-fA-F0-9]{4}-?
+ [1-5][a-fA-F0-9]{3}-?
+ [8-Bab][a-fA-F0-9]{3}-?
+ [a-fA-F0-9]{4}-?
+ [a-fA-F0-9]{4}-?
+ [a-fA-F0-9]{4}-?\}?\z}x
+
def type
:uuid
end
def type_cast(value)
- value.presence
+ value.to_s[RFC_4122, 0]
end
end
end