From: Brad H. <bh...@vp...> - 2002-08-23 17:21:44
|
Hi, I have a patch for Pg.rb which fixes problems handling backslashes in strings. Could someone please review/commit it? Note: the second diff is necessary for proper quoting of placeholder values. The default quote() method in sql.rb was being used without that change. Thanks, -Brad --- Pg.rb Wed Jul 3 13:11:23 2002 +++ /usr/local/lib/ruby/site_ruby/1.6/DBD/Pg/Pg.rb Thu Aug 22 16:03:15 2002 @@ -304,6 +304,15 @@ @connection.exec(sql) end + def quote(value) + case value + when String + "'#{ value.gsub(/\\/){ '\\\\' }.gsub(/'/){ '\\\'' } }'" + else + super + end + end + private # ---------------------------------------------------- def initialize_autocommit @@ -411,7 +420,7 @@ def initialize(db, sql) @db = db - @prep_sql = DBI::SQL::PreparedStatement.new(self, sql) + @prep_sql = DBI::SQL::PreparedStatement.new(@db, sql) @result = nil @bindvars = [] end |