Module: SqlSafetyNet::ExplainPlan
- Defined in:
- lib/sql_safety_net/explain_plan.rb,
lib/sql_safety_net/explain_plan/mysql.rb,
lib/sql_safety_net/explain_plan/postgresql.rb
Overview
Query plan analysis is supported out of the box for MySQL and PostgreSQL.
If you wish to implement it for another database, you’ll need to create a module that defines the sql_safety_net_analyze_query_plan
method and takes arguments for the sql to execute and an array of bind values.
Defined Under Namespace
Modules: Mysql, Postgresql
Class Method Summary collapse
-
.enable_on_connection_adapter!(connection_adapter_class, explain_plan_analyzer) ⇒ Object
Enable query plan analysize on a connection adapter class.
Class Method Details
.enable_on_connection_adapter!(connection_adapter_class, explain_plan_analyzer) ⇒ Object
Enable query plan analysize on a connection adapter class. The explain_plan_analyzer argument can either be :mysql
, :postgresql
or a module that defines a sql_safety_net_analyze_query_plan(sql, binds)
method.
15 16 17 18 19 20 21 |
# File 'lib/sql_safety_net/explain_plan.rb', line 15 def enable_on_connection_adapter!(connection_adapter_class, explain_plan_analyzer) if explain_plan_analyzer.is_a?(Symbol) class_name = explain_plan_analyzer.to_s.camelize explain_plan_analyzer = ExplainPlan.const_get(class_name) end connection_adapter_class.send(:include, explain_plan_analyzer) unless connection_adapter_class.include?(explain_plan_analyzer) end |