From 12e9a75f227ea7bcc23e2717e9ff5a72ec64e1f1 Mon Sep 17 00:00:00 2001 From: Konstantin Shabanov Date: Tue, 12 Jun 2012 18:10:08 +0400 Subject: Add uuid type support to PostgreSQL adapter --- .../lib/active_record/connection_adapters/postgresql/oid.rb | 1 + .../active_record/connection_adapters/postgresql_adapter.rb | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb index df3d5e4657..6657491c06 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb @@ -223,6 +223,7 @@ module ActiveRecord alias_type 'bit', 'text' alias_type 'varbit', 'text' alias_type 'macaddr', 'text' + alias_type 'uuid', 'text' # FIXME: I don't think this is correct. We should probably be returning a parsed date, # but the tests pass with a string returned. diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 03c318f5f7..b08c59d97d 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -89,7 +89,6 @@ module ActiveRecord else string end - end def cidr_to_string(object) @@ -256,7 +255,7 @@ module ActiveRecord :integer # UUID type when 'uuid' - :string + :uuid # Small and big integer types when /^(?:small|big)int$/ :integer @@ -319,6 +318,10 @@ module ActiveRecord def macaddr(name, options = {}) column(name, 'macaddr', options) end + + def uuid(name, options = {}) + column(name, 'uuid', options) + end end ADAPTER_NAME = 'PostgreSQL' @@ -341,7 +344,8 @@ module ActiveRecord :hstore => { :name => "hstore" }, :inet => { :name => "inet" }, :cidr => { :name => "cidr" }, - :macaddr => { :name => "macaddr" } + :macaddr => { :name => "macaddr" }, + :uuid => { :name => "uuid" } } # Returns 'PostgreSQL' as adapter name for identification purposes. -- cgit v1.2.3