rails/rails — pull request #7383 by ahoward (2012-08-17 22:23:21+00:00)
Title: handle freaky (heroku) bytea configurations

see

http://stackoverflow.com/questions/8539207/activerecord-loads-binary-field-incorrectly-on-heroku-fine-on-osx

https://gist.github.com/3382094

https://devcenter.heroku.com/articles/heroku-postgresql#troubleshooting

to try to understand the issue this works around.

essentially, under certain conditions, PGconn.unescape_bytea is returning bunk/different data. this feature detects the situation and corrects it on the fly.