serialized hashes need a NULLIF, as do many other fields, probably

This commit is contained in:
Raphael 2011-01-06 17:26:08 -08:00
parent 89a41826c1
commit abdb5f7587
2 changed files with 7 additions and 5 deletions

View file

@ -75,8 +75,9 @@ module DataConversion
Mongo::Comment.connection.execute <<-SQL
#{load_string("comments")}
#{infile_opts}
(mongo_id, post_mongo_id, person_mongo_id, @diaspora_handle, text, youtube_titles)
SET guid = mongo_id;
(mongo_id, post_mongo_id, person_mongo_id, @diaspora_handle, text, @youtube_titles)
SET guid = mongo_id,
youtube_titles = NULLIF(@youtube_titles, '');
SQL
log "Finished. Imported #{Mongo::Comment.count} comments."
end
@ -85,8 +86,9 @@ module DataConversion
Mongo::Post.connection.execute <<-SQL
#{load_string("posts")}
#{infile_opts}
(youtube_titles,@pending,created_at,@public,updated_at,status_message_mongo_id,caption,remote_photo_path,remote_photo_name,random_string,image,mongo_id,type,diaspora_handle,person_mongo_id,message)
(@youtube_titles,@pending,created_at,@public,updated_at,status_message_mongo_id,caption,remote_photo_path,remote_photo_name,random_string,image,mongo_id,type,diaspora_handle,person_mongo_id,message)
SET guid = mongo_id,
youtube_titles = NULLIF(@youtube_titles, ''),
#{boolean_set("pending")},
#{boolean_set("public")};
SQL

View file

@ -76,7 +76,7 @@ describe DataConversion::ImportToMysql do
comment.text.should == "Hey me!"
comment.person_mongo_id.should == "4d26212bcc8cb44df2000014"
comment.post_mongo_id.should == "4d262132cc8cb44df2000025"
comment.youtube_titles.should == ""
comment.youtube_titles.should be_nil
end
end
describe "contacts" do
@ -136,7 +136,7 @@ describe DataConversion::ImportToMysql do
it "imports all the columns" do
@migrator.import_raw_posts
post = Mongo::Post.first
post.youtube_titles.should == {}
post.youtube_titles.should be_nil
post.pending.should == false
post.created_at.to_i.should == 1294358525000
post.public.should == false