
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
-
Dan Kubb (dkubb) May 22nd, 2010 @ 03:56 PM
- State changed from new to unconfirmed
- Assigned user set to Piotr Solnica (solnic)
-
Dan Kubb (dkubb) May 26th, 2010 @ 02:04 AM
- Milestone set to 1.0.0
-
Piotr Solnica (solnic) May 26th, 2010 @ 04:02 AM
- State changed from unconfirmed to confirmed
-
Piotr Solnica (solnic) June 2nd, 2010 @ 06:37 AM
- State changed from confirmed to resolved
It's resolved in terms of typecasting, now you can use arrays as values w/o any problems; however, there's a different issue in the example code - you cannot use [1,2,3] as CSV lib won't be able to do anything with that. If you used an array of arrays, for instance [[1,2,3]], then it would work just fine.
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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »