开发者

In Rails Marshal dumped data is not saving in its full length in mysql

开发者 https://www.devze.com 2023-04-08 12:10 出处:网络
Marshal dump data is not saving in the database w开发者_如何转开发ith its full length....why?

Marshal dump data is not saving in the database w开发者_如何转开发ith its full length....why? I am using the Marshal to dump the objects and its length after dumping is around 145873 but after saving that data in the mysql its length is changed, means data is missed.... Its length in database is 2851 I have LongText field in the database. What is the solution to this problem ?

      create_table "report_instances", :force => true do |t|
t.integer  "report_id"
t.integer  "user_id"
t.integer  "role_type_id"
t.integer  "delayed_job_id"
t.datetime "generated_at"
t.text     "result"
t.text     "report_data",    :limit => 2147483647
t.datetime "created_at"
t.datetime "updated_at"
t.boolean  "current",                              :default => true
end


x=Marshal.dump([users, total])

report_instance = report.report_instances.find(:last,:conditions=>["user_id=? and role_type_id=?",usr.id,usr.current_role_type_id])

report_instance.update_attribute(:report_data,x)


i would strongly recommend using a BLOB (with t.binary) to store marshaled objects.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号