Anup Pareek
Anup Pareek

Reputation: 159

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

Marshal dump data is not saving in the database with 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)

Upvotes: 0

Views: 562

Answers (1)

Marian Theisen
Marian Theisen

Reputation: 6352

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

Upvotes: 4

Related Questions