#1286 ✓resolved
kgiszczak

dm-types: Csv type doesn't work as expected

Reported by kgiszczak | May 22nd, 2010 @ 12:13 PM | in 1.0.0

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 'rubygems'
 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 ModelCsv include DataMapper::Resource property :id, Serial property :body, Csv end


DataMapper.auto_migrate!


record = ModelCsv.new :body => [ 1, 2, 3 ] # ruby 1.8.7: #<ModelCsv @id=nil @body="123"> # ruby 1.9.2: #<ModelCsv @id=nil @body="[1, 2, 3]"> p record record.save # ruby 1.8.7: [["123"]] # ruby 1.9.2: [["[1", " 2", " 3]"]] p ModelCsv.first.body


record = ModelCsv.new :body => "1, 2, 3" # ruby 1.8.7: #<ModelCsv @id=nil @body="1, 2, 3"> # ruby 1.9.2: #<ModelCsv @id=nil @body="1, 2, 3"> p record record.save # ruby 1.8.7: [["1", " 2", " 3"]] # ruby 1.9.2: [["1", " 2", " 3"]] p ModelCsv.reverse.first.body

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 »

Pages