mneumann / postgres-pr

A pure-Ruby (pr) library for accessing PostgreSQL databases
http://rubyforge.org/projects/postgres-pr
43 stars 13 forks source link

Backslashes with standard_conforming_strings = ON #2

Open larsch opened 13 years ago

larsch commented 13 years ago

Recent versions of Rails (2.3.6 and newer) set standard_conforming_strings = ON from the PostgreSQL adapter. This breaks handling of backslashes, basically because PGconn.escape assumes that the connection is set to the default behavior (standard_conforming_strings = OFF). As a result, backslashes are escaped, when they should not be.

Workaround: config/initializers/postgres-pr-escape.rb

def PGconn.escape(str)
  str.gsub("'","''")
end