Permalink
Browse files

Put the postgres typemap stuff here instead

  • Loading branch information...
1 parent b0605e9 commit 1810b576c3a1265a9121c319c4196b6ecd2ce1cb Paul Sadauskas committed Sep 26, 2008
Showing with 8 additions and 1 deletion.
  1. +2 −0 dm-types/lib/dm-types.rb
  2. +4 −0 dm-types/lib/dm-types/uuid.rb
  3. +2 −1 dm-types/spec/integration/uuid_spec.rb
View
@@ -26,3 +26,5 @@ module Types
autoload(:BCryptHash, File.join(Pathname(__FILE__).dirname.expand_path, 'dm-types', 'bcrypt_hash'))
end
end
+
+DataMapper::Adapters::PostgresAdapter.type_map.map(::DataMapper::Types::UUID).to('UUID')
@@ -1,4 +1,5 @@
require 'rubygems'
+require 'dm-core/adapters/postgres_adapter'
require 'uuidtools'
module DataMapper
@@ -19,6 +20,8 @@ module Types
# -- Rando Sept 25, 08
#
class UUID < DataMapper::Type
+ primitive 'UUID'
+
def self.load(value, property)
return nil if value.nil?
::UUID.parse(value)
@@ -34,6 +37,7 @@ def self.typecast(value, property)
end
::DataMapper::Property::TYPES << self
+ DataMapper::Adapters::PostgresAdapter.type_map.map(self).to('UUID')
end
end
end
@@ -9,8 +9,9 @@ class UUIDTest
include DataMapper::Resource
property :id, Serial
- property :uuid, DataMapper::Types::UUID
+ property :uuid, ::DataMapper::Types::UUID
end
+
UUIDTest.auto_migrate!
end

0 comments on commit 1810b57

Please sign in to comment.