Class: ScoutApm::Utils::SqlSanitizer
- Inherits:
-
Object
- Object
- ScoutApm::Utils::SqlSanitizer
- 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
Instance Attribute Summary collapse
-
#database_engine ⇒ Object
Returns the value of attribute database_engine.
Instance Method Summary collapse
-
#initialize(sql) ⇒ SqlSanitizer
constructor
A new instance of SqlSanitizer.
- #sql ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(sql) ⇒ SqlSanitizer
Returns a new instance of SqlSanitizer.
17 18 19 20 21 |
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 17 def initialize(sql) @raw_sql = sql @database_engine = ScoutApm::Agent.instance.context.environment.database_engine @sanitized = false # only sanitize once. end |
Instance Attribute Details
#database_engine ⇒ Object
Returns the value of attribute database_engine.
15 16 17 |
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 15 def database_engine @database_engine end |
Instance Method Details
#sql ⇒ Object
23 24 25 |
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 23 def sql @sql ||= scrubbed(@raw_sql.dup) # don't do this in initialize as it is extra work that isn't needed unless we have a slow transaction. end |
#to_s ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/scout_apm/utils/sql_sanitizer.rb', line 27 def to_s if @sanitized sql else @sanitized = true end case database_engine when :postgres then to_s_postgres when :mysql then to_s_mysql when :sqlite then to_s_sqlite end end |