I made a following csv fixture and executed insertion test, but it failed.
(in ACTIVE_RECORD/test/fixtures/csv/topics.csv)
id,title,author_name,author_email_address,written_on,bonus_time,last_read,content,approved,replies_count,parent_id,type,
1,The First Topic,David,david@loudthinking.com,2003-07-16 15:28:11,2005-01-30 15:28:00,2004/4/15,Have a nice day,0,1,,
2,The Second Topic's of the day,Mary,,2003-07-15 15:28:00,,,Have a nice day,1,0,1,Replay
(in ACTIVE_RECORD/test/fixtures_test.rb)
def test_csv_inserts
topics = create_fixtures("csv/topics")
firstRow = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
assert_equal("The First Topic", firstRow["title"])
secondRow = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'Mary'")
assert_nil(secondRow["author_email_address"])
end
(test result)
1) Error:
test_csv_inserts(FixturesTest):
ActiveRecord::StatementInvalid: Mysql::Error: #22003Out of range value adjusted
for column 'parent_id' at row 1: INSERT INTO topics (`author_name`, `title`, `type`, `approved`, `id`, `replies_count`, `bonus_time`, `content`, `written_on`, `author_email_address`, `parent_id`, `last_read`) VALUES ('David', 'The First Topic', '', '0', '1', '1', '2005-01-30 15:28:00', 'Have a nice day', '2003-07-16 15:28:11', 'david@loudthinking.com', '', '2004/4/15')
In the rails guide (http://manuals.rubyonrails.com/read/chapter/26#page65), it is said,
nulls can be achived by just placing a comma, for example, (1,sclaus,,false,) minus the parenthesis of course.
but an emtpy cell seems to be archived as an empty string.
I attach the fixtures.rb patch for this issue to be resolved.