diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 090258e07a55d19c61ed6f188d8e90a71b963dd5..463f784036346ef60f5d3864e80ad0e88185f069 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added check for RAILS_CONNECTION_ADAPTERS on startup and only load the connection adapters specified within if its present (available in Rails through config.connection_adapters using the new config) #1958 + * Fixed various problems with has_and_belongs_to_many when using customer finder_sql #2094 [Florian Weber] * Added better exception error when unknown column types are used with migrations #1814 [fbeausoleil@ftml.net] diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb index ac3f12239a6c5dbe45a03f6e0705104d4f82d06b..d7e7201e73bd4c85b661a86671ac7d95ad705357 100755 --- a/activerecord/lib/active_record.rb +++ b/activerecord/lib/active_record.rb @@ -63,11 +63,12 @@ include ActiveRecord::Acts::NestedSet end -require 'active_record/connection_adapters/mysql_adapter' -require 'active_record/connection_adapters/postgresql_adapter' -require 'active_record/connection_adapters/sqlite_adapter' -require 'active_record/connection_adapters/sqlserver_adapter' -require 'active_record/connection_adapters/db2_adapter' -require 'active_record/connection_adapters/oci_adapter' +unless defined?(RAILS_CONNECTION_ADAPTERS) + RAILS_CONNECTION_ADAPTERS = %w(mysql postgresql sqlite sqlserver db2 oci) +end + +RAILS_CONNECTION_ADAPTERS.each do |adapter| + require "active_record/connection_adapters/#{adapter}_adapter" +end -require 'active_record/query_cache' +require 'active_record/query_cache' \ No newline at end of file diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb index f8b95505cf3e7b2513f2797cec1d57ede907a193..14654dff0049f2b5ca7814f1e671912db3adf3d4 100644 --- a/railties/environments/environment.rb +++ b/railties/environments/environment.rb @@ -18,6 +18,9 @@ # (by default production uses :info, the others :debug) # config.log_level = :debug + # Only include the connection adapters you're actually going to use + # config.connection_adapters = %w( mysql sqlite ) + # Use the database for sessions instead of the file system # (create the session table with 'rake create_sessions_table') # config.action_controller.session_store = :active_record_store diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index 8e99c708c2974669933e78708d30c4a5fabeaf39..5b80ab5bd57d8823b56c65b81748df48065769f1 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -30,6 +30,7 @@ def initialize(configuration) def process set_load_path + set_connection_adapters require_frameworks load_environment @@ -56,6 +57,10 @@ def set_load_path $LOAD_PATH.uniq! end + def set_connection_adapters + RAILS_CONNECTION_ADAPTERS = configuration.connection_adapters + end + def require_frameworks configuration.frameworks.each { |framework| require(framework.to_s) } end @@ -143,6 +148,7 @@ def intitialize_framework_settings class Configuration attr_accessor :frameworks, :load_paths, :logger, :log_level, :log_path, :database_configuration_file, :view_path, :controller_paths attr_accessor :cache_classes, :breakpoint_server, :whiny_nils + attr_accessor :connection_adapters attr_accessor :active_record, :action_controller, :action_view, :action_mailer, :action_web_service def initialize @@ -155,6 +161,7 @@ def initialize self.cache_classes = default_cache_classes self.breakpoint_server = default_breakpoint_server self.whiny_nils = default_whiny_nils + self.connection_adapters = default_connection_adapters self.database_configuration_file = default_database_configuration_file for framework in default_frameworks @@ -258,5 +265,9 @@ def default_breakpoint_server def default_whiny_nils false end + + def default_connection_adapters + %w(mysql postgresql sqlite sqlserver db2 oci) + end end end