Module: Cucumber::ThinkingSphinx::SqlLogger
- Defined in:
- lib/cucumber/thinking_sphinx/sql_logger.rb
Constant Summary collapse
- IGNORED_SQL =
[ /^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/, /^SHOW FIELDS/ ]
Class Method Summary collapse
Instance Method Summary collapse
- #execute_with_query_record(sql, name = 'SQL', &block) ⇒ Object
- #log(sql, name = 'SQL', binds = []) ⇒ Object
Class Method Details
.included(base) ⇒ Object
16 17 18 |
# File 'lib/cucumber/thinking_sphinx/sql_logger.rb', line 16 def self.included(base) base.send :alias_method_chain, :execute, :query_record end |
Instance Method Details
#execute_with_query_record(sql, name = 'SQL', &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/cucumber/thinking_sphinx/sql_logger.rb', line 20 def execute_with_query_record(sql, name = 'SQL', &block) $queries_executed ||= [] $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r } execute_without_query_record(sql, name, &block) end |
#log(sql, name = 'SQL', binds = []) ⇒ Object
10 11 12 13 14 |
# File 'lib/cucumber/thinking_sphinx/sql_logger.rb', line 10 def log(sql, name = 'SQL', binds = []) $queries_executed ||= [] $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r } super sql, name, binds end |