class Honeybadger::Util::SQL

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/honeybadger/util/sql.rbs

class Honeybadger::Util::SQL
  def self.force_utf_8: (String string) -> String
  def self.obfuscate: (String sql, String adapter) -> String
end

def self.force_utf_8(string)

Experimental RBS support (using type sampling data from the type_fusion project).

def self.force_utf_8: (String string) -> String

This signature was generated using 116 samples from 1 application.

def self.force_utf_8(string)
  string.encode(
    Encoding.find('UTF-8'),
    invalid: :replace, 
    undef: :replace, 
    replace: ''
  )
end

def self.obfuscate(sql, adapter)

Experimental RBS support (using type sampling data from the type_fusion project).

def self.obfuscate: (String sql, String adapter) -> String

This signature was generated using 56 samples from 1 application.

def self.obfuscate(sql, adapter)
  force_utf_8(sql.dup).tap do |s|
    s.gsub!(EscapedQuotes, EmptyReplacement)
    s.gsub!(SQuotedData, Replacement)
    s.gsub!(DQuotedData, Replacement) if adapter =~ DoubleQuoters
    s.gsub!(NumericData, Replacement)
    s.gsub!(Newline, EmptyReplacement)
    s.squeeze!(' ')
  end
end