#1285 ✓resolved
kgiszczak

dm-types: issues with Json, FilePath, IPAddress types

Reported by kgiszczak | May 22nd, 2010 @ 11:16 AM

Models aren't saved when property with one of this type is set.
There's no problem with other types.

Gemfile:

 source 'http://rubygems.org'
 gem 'dm-migrations',        '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-migrations.git'
 gem 'dm-types',             '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-types.git'
 gem 'dm-postgres-adapter',  '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-postgres-adapter.git'
 gem 'dm-mysql-adapter',     '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-mysql-adapter.git'
 gem 'dm-sqlite-adapter',    '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-sqlite-adapter.git'
 gem 'dm-core',              '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-core.git'
 gem 'dm-do-adapter',        '~> 1.0.0.rc2',  :git => 'git://github.com/datamapper/dm-do-adapter.git'
 gem 'json'

test.rb:

 require 'bundler'
 Bundler.setup
 Bundler.require(:default)


DataMapper.setup(:default, 'postgres://postgres@localhost/test') # DataMapper.setup(:default, 'mysql://root@localhost/test') # DataMapper.setup(:default, 'sqlite3::memory:')


class ModelIpAddress include DataMapper::Resource property :id, Serial property :addr, IPAddress end class ModelFilePath include DataMapper::Resource property :id, Serial property :body, FilePath end class ModelJson include DataMapper::Resource property :id, Serial property :body, Json end


DataMapper.auto_migrate!


record = ModelIpAddress.new :addr => '127.0.0.1' p record # => #<ModelIpAddress @id=nil @addr=#<IPAddr: IPv4:127.0.0.1/255.255.255.255>> p record.save # => true p ModelIpAddress.all # => []


record = ModelFilePath.new :body => '/usr/local' p record # => #<ModelFilePath @id=nil @body=#<Pathname:/usr/local>> p record.save # => true p ModelFilePath.all # => []


record = ModelJson.new :body => { :tast => "test" } p record # => #<ModelJson @id=nil @body={:tast=>"test"}> p record.save # => true p ModelJson.all # => []

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Referenced by

Pages