Forum: Ruby on Rails Escape bytea binary data in postgres SQL

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
27ee418c810e50632485c592ae512e2c?d=identicon&s=25 rickthemick (Guest)
on 2005-12-21 10:38
Hi!
I want to escape binary data correctly either manually or using some
pre-defined function that does this for me!

I have found on the web: PGconn.escape_bytea but I only get "undefined
method". Any ideas, what is the correct way of doing this my self?

I'm using Rails (WEBrick) under Windows XP with postgre-pr 0.4.0

I have tried:

s_buffer = s_buffer.gsub(/[']/, '\\047')
s_buffer = s_buffer.gsub(/[\\]/, '\\134')
s_buffer = s_buffer.gsub(/[\0]/, '\\000')

/Rick
59de94a56fd2c198f33d9515d1c05961?d=identicon&s=25 Tom Mornini (Guest)
on 2005-12-21 16:10
(Received via mailing list)
The ActiveRecord does this automatically, as necessary.

Or, I've been *very* lucky storing uploaded photos in a
BYTEA in PostgreSQL.

--
-- Tom Mornini
This topic is locked and can not be replied to.