Skip to content

Backslashes with standard_conforming_strings = ON #2

@larsch

Description

@larsch

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions