Class: ScoutApm::Utils::SqlSanitizer

Inherits:
Object
  • Object
show all
Includes:
SqlRegex
Defined in:
lib/scout_apm/utils/sql_sanitizer.rb

Constant Summary

Constants included from SqlRegex

ScoutApm::Utils::SqlRegex::MULTIPLE_QUESTIONS, ScoutApm::Utils::SqlRegex::MULTIPLE_SPACES, ScoutApm::Utils::SqlRegex::MYSQL_IN_CLAUSE, ScoutApm::Utils::SqlRegex::MYSQL_REMOVE_DOUBLE_QUOTE_STRINGS, ScoutApm::Utils::SqlRegex::MYSQL_REMOVE_INTEGERS, ScoutApm::Utils::SqlRegex::MYSQL_REMOVE_SINGLE_QUOTE_STRINGS, ScoutApm::Utils::SqlRegex::MYSQL_VAR_INTERPOLATION, ScoutApm::Utils::SqlRegex::PSQL_IN_CLAUSE, ScoutApm::Utils::SqlRegex::PSQL_PLACEHOLDER, ScoutApm::Utils::SqlRegex::PSQL_REMOVE_INTEGERS, ScoutApm::Utils::SqlRegex::PSQL_REMOVE_STRINGS, ScoutApm::Utils::SqlRegex::PSQL_VAR_INTERPOLATION, ScoutApm::Utils::SqlRegex::SQLITE_REMOVE_INTEGERS, ScoutApm::Utils::SqlRegex::SQLITE_REMOVE_STRINGS, ScoutApm::Utils::SqlRegex::SQLITE_VAR_INTERPOLATION, ScoutApm::Utils::SqlRegex::TRAILING_SPACES

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sql) ⇒ SqlSanitizer

Returns a new instance of SqlSanitizer.



18
19
20
21
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 18

def initialize(sql)
  @sql = scrubbed(sql.dup)
  @database_engine = ScoutApm::Environment.instance.database_engine
end

Instance Attribute Details

#database_engineObject

Returns the value of attribute database_engine.



16
17
18
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 16

def database_engine
  @database_engine
end

#sqlObject (readonly)

Returns the value of attribute sql.



15
16
17
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 15

def sql
  @sql
end

Instance Method Details

#to_sObject



23
24
25
26
27
28
29
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 23

def to_s
  case database_engine
  when :postgres then to_s_postgres
  when :mysql    then to_s_mysql
  when :sqlite   then to_s_sqlite
  end
end