1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

support for assert_queries when using Oracle adapter

initialize $KCODE to UTF8 when JRuby is used
This commit is contained in:
Raimonds Simanovskis 2009-03-23 00:27:48 +02:00
parent 090ec47bec
commit 8f34c96614

View file

@ -1,8 +1,8 @@
# gem "rsim-activerecord-oracle_enhanced-adapter"
# gem "activerecord-oracle_enhanced-adapter"
gem "activerecord-oracle_enhanced-adapter", ">=1.2.0"
# uses local copy of oracle_enhanced adapter
$:.unshift("../../oracle-enhanced/lib")
require 'active_record/connection_adapters/oracle_enhanced_adapter'
# $:.unshift("../../oracle-enhanced/lib")
# require 'active_record/connection_adapters/oracle_enhanced_adapter'
print "Using Oracle\n"
require_dependency 'models/course'
@ -13,7 +13,7 @@ require 'logger'
ActiveRecord::Base.logger = Logger.new("debug.log")
# Set these to your database connection strings
db = ENV['ARUNIT_DB'] || 'XE'
db = ENV['ARUNIT_DB_NAME'] = 'XE'
ActiveRecord::Base.configurations = {
'arunit' => {
@ -36,3 +36,19 @@ ActiveRecord::Base.configurations = {
ActiveRecord::Base.establish_connection 'arunit'
Course.establish_connection 'arunit2'
# for assert_queries test helper
ActiveRecord::Base.connection.class.class_eval do
IGNORED_SELECT_SQL = [/^select .*nextval/i, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/, /^\s*select .* from all_tab_columns/im]
def select_with_query_record(sql, name = nil, return_column_names = false)
$queries_executed ||= []
$queries_executed << sql unless IGNORED_SELECT_SQL.any? { |r| sql =~ r }
select_without_query_record(sql, name, return_column_names)
end
alias_method_chain :select, :query_record
end
# For JRuby Set default $KCODE to UTF8
$KCODE = "UTF8" if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'