Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Postgres bytea value integrity broken on import #443
I seem to have uncovered a bug with how values are quoted when it comes to PG's binary "bytea" column. Basically upon import, the integrity of our encrypted data is broken as a result.
I've traced the problem line to here: ActiveRecord::Import:L756:
The issue is that
If we have an encrypted string, e.g.:
The issue here is that multiple adjacent slashes (e.g.
To work around this, we basically need to preemptively escape the encryption string before ActiveRecord::Import unescapes/escapes it. This means each encrypted value is escaped/unescaped/escaped though, which is obviously inefficient.
I guess I'm wondering if it's necessary to call
If that can't be removed, can you think of a better workaround?
Thanks for the help :)
The issue can further be demonstrated with:
The problem is that
I've fixed the issue with a monkey patch modifying
The key part that changed being: