diff --git a/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb b/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb index 7eba1db4a..7b46307bc 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced_jdbc_connection.rb @@ -82,9 +82,12 @@ def new_connection(config) config[:driver] ||= @raw_connection.meta_data.connection.java_class.name username = @raw_connection.meta_data.user_name else - username, password, database = config[:username], config[:password], config[:database] - privilege = config[:privilege] && config[:privilege].to_s + # to_s needed if username, password or database is specified as number in database.yml file + username = config[:username] && config[:username].to_s + password = config[:password] && config[:password].to_s + database = config[:database] && config[:database].to_s host, port = config[:host], config[:port] + privilege = config[:privilege] && config[:privilege].to_s # connection using TNS alias if database && !host && !config[:url] && ENV['TNS_ADMIN'] diff --git a/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb b/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb index a389c5bb3..ffe710060 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb @@ -251,7 +251,10 @@ def create_time_with_default_timezone(value) # configure an Oracle/OCI connection. class OracleEnhancedOCIFactory #:nodoc: def self.new_connection(config) - username, password, database = config[:username], config[:password], config[:database] + # to_s needed if username, password or database is specified as number in database.yml file + username = config[:username] && config[:username].to_s + password = config[:password] && config[:password].to_s + database = config[:database] && config[:database].to_s host, port = config[:host], config[:port] privilege = config[:privilege] && config[:privilege].to_sym async = config[:allow_concurrency] @@ -260,7 +263,6 @@ def self.new_connection(config) # get session time_zone from configuration or from TZ environment variable time_zone = config[:time_zone] || ENV['TZ'] - # connection using TNS alias # if TNS_ADMIN is not specified then $ORACLE_HOME/network/admin/ is used as default by Oracle client connection_string = if database && !host && (ENV['TNS_ADMIN'] || ENV['ORACLE_HOME']) diff --git a/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb b/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb index a40be6f7c..6bcb829e3 100644 --- a/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +++ b/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb @@ -60,9 +60,23 @@ end end + describe "with non-string parameters" do + before(:all) do + params = CONNECTION_PARAMS.dup + params[:username] = params[:username].to_sym + params[:password] = params[:password].to_sym + params[:database] = params[:database].to_sym + @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params) + end + + it "should create new connection" do + @conn.should be_active + end + end + if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' - describe "OracleEnhancedConnection create JDBC connection" do + describe "create JDBC connection" do it "should create new connection using :url" do params = CONNECTION_PARAMS.dup