Ticket #6580: sqlserver_adapter_trusted_connection.patch
| File sqlserver_adapter_trusted_connection.patch, 3.8 kB (added by catan512, 2 years ago) |
|---|
-
activerecord/test/connections/native_sqlserver/connection.rb
old new 16 16 :host => 'localhost', 17 17 :username => 'sa', 18 18 :database => 'activerecord_unittest2' 19 }, 20 'arunit_trusted' => { 21 :adapter => 'sqlserver', 22 :host => 'localhost', 23 :windows_auth => true, 24 :database => 'activerecord_unittest' 19 25 } 20 26 } 21 27 -
activerecord/test/adapter_test_sqlserver.rb
old new 14 14 @connection.execute("SET LANGUAGE us_english") 15 15 end 16 16 17 def test_trusted_connection 18 # open trusted connection 19 ActiveRecord::Base.establish_connection 'arunit_trusted' 20 @connection = ActiveRecord::Base.connection 21 assert_equal true, @connection.active? 22 # restore old connection 23 ActiveRecord::Base.establish_connection 'arunit' 24 @connection = ActiveRecord::Base.connection 25 assert_equal true, @connection.active? 26 end 27 17 28 # SQL Server 2000 has a bug where some unambiguous date formats are not 18 29 # correctly identified if the session language is set to german 19 30 def test_date_insertion_when_language_is_german -
activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
old new 32 32 mode = config[:mode] ? config[:mode].to_s.upcase : 'ADO' 33 33 username = config[:username] ? config[:username].to_s : 'sa' 34 34 password = config[:password] ? config[:password].to_s : '' 35 auth = config[:windows_auth] ? 'Integrated Security=SSPI' : "User ID=#{username};Password=#{password}" 35 36 autocommit = config.key?(:autocommit) ? config[:autocommit] : true 36 37 if mode == "ODBC" 37 38 raise ArgumentError, "Missing DSN. Argument ':dsn' must be set in order for this adapter to work." unless config.has_key?(:dsn) … … 41 42 raise ArgumentError, "Missing Database. Argument ':database' must be set in order for this adapter to work." unless config.has_key?(:database) 42 43 database = config[:database] 43 44 host = config[:host] ? config[:host].to_s : 'localhost' 44 driver_url = "DBI:ADO:Provider=SQLOLEDB;Data Source=#{host};Initial Catalog=#{database}; User Id=#{username};Password=#{password};"45 driver_url = "DBI:ADO:Provider=SQLOLEDB;Data Source=#{host};Initial Catalog=#{database};#{auth};" 45 46 end 46 47 conn = DBI.connect(driver_url, username, password) 47 48 conn["AutoCommit"] = autocommit … … 167 168 # 168 169 # * <tt>:mode</tt> -- ADO or ODBC. Defaults to ADO. 169 170 # * <tt>:username</tt> -- Defaults to sa. 170 # * <tt>:password</tt> -- Defaults to empty string. 171 # * <tt>:password</tt> -- Defaults to empty string. 172 # * <tt>:windows_auth</tt> -- Defaults to "User ID=#{username};Password=#{password}" 171 173 # 172 174 # ADO specific options: 173 175 # 174 176 # * <tt>:host</tt> -- Defaults to localhost. 175 # * <tt>:database</tt> -- The name of the database. No default, must be provided. 177 # * <tt>:database</tt> -- The name of the database. No default, must be provided. 178 # * <tt>:windows_auth</tt> -- Use windows authentication instead of username/password. 176 179 # 177 180 # ODBC specific options: 178 181 #