Skip to content

Commit

Permalink
Older mysql2 and SQL logging for Rails 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Jan 22, 2012
1 parent d1ed078 commit 517940e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions Appraisals
@@ -1,6 +1,7 @@
appraise 'rails_3_0' do appraise 'rails_3_0' do
gem 'activerecord', '~> 3.0.3' gem 'activerecord', '~> 3.0.3'
gem 'actionpack', '~> 3.0.3' gem 'actionpack', '~> 3.0.3'
gem 'mysql2', '~> 0.2.18', :platform => :ruby
end end


appraise 'rails_3_1' do appraise 'rails_3_1' do
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_3_0.gemfile
Expand Up @@ -3,11 +3,11 @@
source :rubygems source :rubygems


gem "rcov", "0.9.8", :platform=>:mri_18 gem "rcov", "0.9.8", :platform=>:mri_18
gem "mysql2", "~> 0.3.7", :platform=>:ruby
gem "pg", "~> 0.11.0", :platform=>:ruby gem "pg", "~> 0.11.0", :platform=>:ruby
gem "activerecord-jdbcmysql-adapter", "~> 1.1.3", :platform=>:jruby gem "activerecord-jdbcmysql-adapter", "~> 1.1.3", :platform=>:jruby
gem "activerecord-jdbcpostgresql-adapter", "~> 1.1.3", :platform=>:jruby gem "activerecord-jdbcpostgresql-adapter", "~> 1.1.3", :platform=>:jruby
gem "activerecord", "~> 3.0.3" gem "activerecord", "~> 3.0.3"
gem "actionpack", "~> 3.0.3" gem "actionpack", "~> 3.0.3"
gem "mysql2", "~> 0.2.18", :platform=>:ruby


gemspec :path=>"../" gemspec :path=>"../"
20 changes: 16 additions & 4 deletions lib/cucumber/thinking_sphinx/sql_logger.rb
Expand Up @@ -6,10 +6,22 @@ module SqlLogger
/^SELECT @@ROWCOUNT/, /^SHOW FIELDS/ /^SELECT @@ROWCOUNT/, /^SHOW FIELDS/
] ]


def log(sql, name = 'SQL', binds = []) if ActiveRecord::VERSION::STRING.to_f > 3.0
$queries_executed ||= [] def log(sql, name = 'SQL', binds = [])
$queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r } $queries_executed ||= []
super sql, name, binds $queries_executed << sql unless IGNORED_SQL.any? { |r| sql =~ r }
super sql, name, binds
end
else
def self.included(base)
base.send :alias_method_chain, :execute, :query_record
end

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
end end
end end
end end
Expand Down

0 comments on commit 517940e

Please sign in to comment.