vendor/bundle/ruby/2.1.0/gems/newrelic_rpm-3.9.4.245/lib/new_relic/agent/database/obfuscation_helpers.rb
# Note that the following two regexes are applied to a reversed version
# of the query. This is why the backslash escape sequences (\' and \")
# appear reversed within them.
#
# Note that some database adapters (notably, PostgreSQL with
# standard_conforming_strings on and MySQL with NO_BACKSLASH_ESCAPES on)
# do not apply special treatment to backslashes within quoted string
# literals. We don't have an easy way of determining whether the
# database connection from which a query was captured was operating in
# one of these modes, but the obfuscation is done in such a way that it
# should not matter.
#
# Reversing the query string before obfuscation allows us to get around
# the fact that a \' appearing within a string may or may not terminate
# the string, because we know that a string cannot *start* with a \'.
Note that the following two regexes are applied to a reversed version
of the query. This is why the backslash escape sequences (\' and \")
appear reversed within them.

Note that some database adapters (notably, PostgreSQL with
standard_conforming_strings on and MySQL with NO_BACKSLASH_ESCAPES on)
do not apply special treatment to backslashes within quoted string
literals. We don't have an easy way of determining whether the
database connection from which a query was captured was operating in
one of these modes, but the obfuscation is done in such a way that it
should not matter.

Reversing the query string before obfuscation allows us to get around
the fact that a \' appearing within a string may or may not terminate
the string, because we know that a string cannot *start* with a \'.
Note that the following two regexes are applied to a reversed version of the query . This is why the backslash escape sequences ( \ ' and \ " ) appear reversed within them . Note that some database adapters ( notably PostgreSQL with standard_conforming_strings on and MySQL with NO_BACKSLASH_ESCAPES on ) do not apply special treatment to backslashes within quoted string literals . We don ' t have an easy way of determining whether the database connection from which a query was captured was operating in one of these modes but the obfuscation is done in such a way that it should not matter . Reversing the query string before obfuscation allows us to get around the fact that a \ ' appearing within a string may or may not terminate the string because we know that a string cannot * start * with a \ ' .
def obfuscate_single_quote_literals(sql)
          obfuscated = sql.reverse
          obfuscated.gsub!(REVERSE_SINGLE_QUOTES_REGEX, PLACEHOLDER)
          obfuscated.reverse!
          obfuscated
        end
def obfuscate_single_quote_literals ( sql ) obfuscated = sql . reverse obfuscated . gsub! ( REVERSE_SINGLE_QUOTES_REGEX , PLACEHOLDER ) obfuscated . reverse! obfuscated end
Note that the following two regexes are applied to a reversed version
of the query.
Note that the following two regexes are applied to a reversed version of the query .
sql