rails/rails — pull request #10830 by mrbrdo (2013-06-05 16:10:56+00:00)
Title: Rails 4 bytea/binary not unescaped?

I have a bytea field in postgres (says binary in schema.rb).

There seems to be different behavior in Rails 4 compared to Rails 3.2.
If I use ActiveRecord::Base.connection.execute to get raw data, I get the same data in both versions.

However when I inspect the value that ActiveRecord gives me when reading the attribute from the model, I get a different value.

Raw: "\\x789c63e108010000730061"
Rails 3.2: "x\x9Cc\xE1\b\x01\x00\x00s\x00a"
Rails 4: "\\x789c63e108010000730061"

Obviously this is causing problems for me. What's wrong?
PS: I was using **postgres_ext** and activerecord-postgres-hstore gems in Rails 3.2, removed in Rails 4. I'm getting this issue during upgrading to Rails 4.

PS: It seems I can get the same string in Rails 4 by doing PGconn.unescape_bytea on the string. Did someone forget to unescape it or something? If this is intended I think it should be included in http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html

Thanks.