rails/rails — pull request #13827 by scosman (2014-01-24 17:43:37+00:00)
Title: Update postgres hstore casting to handle null-terminated strings.

This is needed because ruby doesn't null terminate strings, but the PG connection adapter does. Without this, trying to use a string containing null in an hstore will always result in invalid SQL ("Unexpected end of string").

I chose to truncate the string at the first \0 to be consistent with PG.connection.quote_string and the C PQescapeStringConn. This is the same behaviour AR silently applies to text/varchar so I think it's a good fit.

To test:
ARCONN=postgresql ruby -Itest test/cases/adapters/postgresql/hstore_test.rb