I am wondering what are the dis/advantages of storing ruby serialized objects (i.e. Marshal.dump) directly into a `bytea` column versus Base64 encoding the byte stream and storing into a `text` column? Also, are there any performance concerns with either method? I am using PostgreSQL to be specific.
One of the advantages I found in base64 encoding first is that it doesn't screw up my terminal when Sequel logs to STDOUT. Maybe there is a way to escape or hide this binary data in the logger? However, it seems storing the serialized object directly, without encoding, would be more efficient. (this may make this post irrelevant) Finally, I was unable to reconstitute a ruby object after an insert/select. I keep getting the error from Marshal.dump, "data too short". It wasn't until I base64 encoded first that I got it to work. So maybe storing binary data directly doesn't work? I found a post from 2008, How do you insert binary data using sequel + postgresql?<https://groups.google.com/forum/#!searchin/sequel-talk/ruby$20binary/sequel-talk/4aRQGNPQ7Po/_hdJMmZ2Ki4J> Here's what I did: ds = DB[:core__checkout_snapshots] checkout_data = Marshal.dump(data) ds.insert(id: checkout_id, data: checkout_data) Marshal.load(ds[id: checkout_id][:data]) This failed with the `data` column as type `bytea` and `text`. -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/xc_xJhLlfVoJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
