Class: SqlSafetyNet::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/sql_safety_net/configuration.rb

Overview

This class provides configuration options for SQL analysis.

These options specify when a warning will be triggered based on the totals from all queries in a single request:

  • query_limit - the total number of queries (default to 10)

  • returned_rows_limit - the total number of rows returned (defaults to 100)

  • result_size_limit - the number of bytes returned by all queries (defaults to 16K)

  • elapsed_time_limit - the number of seconds taken for all queries (defaults to 0.3)

These options specify when a warning will be triggered on a single query. These options are only available when using MySQL:

  • table_scan_limit - the number of rows in a table scan that will trigger a warning (defaults to 100)

  • temporary_table_limit - the number of temporary table rows that will trigger a warning (defaults to 100)

  • filesort_limit - the number of rows in a filesort operation that will trigger a warning (defaults to 100)

  • examined_rows_limit - the number of rows examined in a query that will trigger a warning (defaults to 5000)

These options specify details about embedding debugging info in HTML pages

  • always_show - set to true to always show debugging info; otherwise only shown if the request is flagged (defaults to false)

  • style - set to a hash of CSS styles used to style the debugging info; defaults to appearing in the upper right corner

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sql_safety_net/configuration.rb', line 29

def initialize
  @query_limit = 10
  @returned_rows_limit = 100
  @result_size_limit = 16 * 1024
  @elapsed_time_limit = 0.3
  
  @table_scan_limit = 100
  @temporary_table_limit = 100
  @filesort_limit = 100
  @examined_rows_limit = 5000
  
  @always_show = false
  @style = {}
  
  yield(self) if block_given?
end

Instance Attribute Details

#always_showObject

Returns the value of attribute always_show.



27
28
29
# File 'lib/sql_safety_net/configuration.rb', line 27

def always_show
  @always_show
end

#elapsed_time_limitObject

Returns the value of attribute elapsed_time_limit.



25
26
27
# File 'lib/sql_safety_net/configuration.rb', line 25

def elapsed_time_limit
  @elapsed_time_limit
end

#examined_rows_limitObject

Returns the value of attribute examined_rows_limit.



26
27
28
# File 'lib/sql_safety_net/configuration.rb', line 26

def examined_rows_limit
  @examined_rows_limit
end

#filesort_limitObject

Returns the value of attribute filesort_limit.



26
27
28
# File 'lib/sql_safety_net/configuration.rb', line 26

def filesort_limit
  @filesort_limit
end

#query_limitObject

Returns the value of attribute query_limit.



25
26
27
# File 'lib/sql_safety_net/configuration.rb', line 25

def query_limit
  @query_limit
end

#result_size_limitObject

Returns the value of attribute result_size_limit.



25
26
27
# File 'lib/sql_safety_net/configuration.rb', line 25

def result_size_limit
  @result_size_limit
end

#returned_rows_limitObject

Returns the value of attribute returned_rows_limit.



25
26
27
# File 'lib/sql_safety_net/configuration.rb', line 25

def returned_rows_limit
  @returned_rows_limit
end

#styleObject

Returns the value of attribute style.



27
28
29
# File 'lib/sql_safety_net/configuration.rb', line 27

def style
  @style
end

#table_scan_limitObject

Returns the value of attribute table_scan_limit.



26
27
28
# File 'lib/sql_safety_net/configuration.rb', line 26

def table_scan_limit
  @table_scan_limit
end

#temporary_table_limitObject

Returns the value of attribute temporary_table_limit.



26
27
28
# File 'lib/sql_safety_net/configuration.rb', line 26

def temporary_table_limit
  @temporary_table_limit
end