Ticket #6580: sqlserver_trusted_connection_complete_patch.diff
| File sqlserver_trusted_connection_complete_patch.diff, 3.1 kB (added by tomafro, 1 year 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 19 19 def test_real_column_has_float_type 20 20 assert_equal :float, TableWithRealColumn.columns_hash["real_number"].type 21 21 end 22 23 if ActiveRecord::Base.configurations['arunit_trusted'] 24 def test_trusted_connection 25 # open trusted connection 26 ActiveRecord::Base.establish_connection 'arunit_trusted' 27 @connection = ActiveRecord::Base.connection 28 assert_equal true, @connection.active? 29 # restore old connection 30 ensure 31 ActiveRecord::Base.establish_connection 'arunit' 32 @connection = ActiveRecord::Base.connection 33 assert_equal true, @connection.active? 34 end 35 end 22 36 23 37 # SQL Server 2000 has a bug where some unambiguous date formats are not 24 38 # correctly identified if the session language is set to 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