Changeset 3044
- Timestamp:
- 11/15/05 11:35:14 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r3043 r3044 1 1 *SVN* 2 3 * SQLServer: active? and reconnect! methods for handling stale connections. #428 [kajism@yahoo.com] 2 4 3 5 * Associations handle case-equality more consistently: item.parts.is_a?(Array) and item.parts === Array. #1345 [MarkusQ@reality.com] trunk/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
r3035 r3044 31 31 raise ArgumentError, "Missing DSN. Argument ':dsn' must be set in order for this adapter to work." unless config.has_key?(:dsn) 32 32 dsn = config[:dsn] 33 conn = DBI.connect("DBI:ODBC:#{dsn}", username, password)33 driver_url = "DBI:ODBC:#{dsn}" 34 34 else 35 35 raise ArgumentError, "Missing Database. Argument ':database' must be set in order for this adapter to work." unless config.has_key?(:database) 36 36 database = config[:database] 37 37 host = config[:host] ? config[:host].to_s : 'localhost' 38 conn = DBI.connect("DBI:ADO:Provider=SQLOLEDB;Data Source=#{host};Initial Catalog=#{database};User Id=#{username};Password=#{password};") 39 end 38 driver_url = "DBI:ADO:Provider=SQLOLEDB;Data Source=#{host};Initial Catalog=#{database};User Id=#{username};Password=#{password};" 39 end 40 conn = DBI.connect(driver_url, username, password) 40 41 41 42 conn["AutoCommit"] = true 42 ConnectionAdapters::SQLServerAdapter.new(conn, logger )43 ConnectionAdapters::SQLServerAdapter.new(conn, logger, [driver_url, username, password]) 43 44 end 44 45 end # class Base … … 173 174 # [Linux strongmad 2.6.11-1.1369_FC4 #1 Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux] 174 175 class SQLServerAdapter < AbstractAdapter 176 177 def initialize(connection, logger, connection_options=nil) 178 super(connection, logger) 179 @connection_options = connection_options 180 end 181 175 182 def native_database_types 176 183 { … … 196 203 true 197 204 end 205 206 # CONNECTION MANAGEMENT ====================================# 207 208 # Returns true if the connection is active. 209 def active? 210 @connection.execute("SELECT 1") {|sth|} 211 true 212 rescue DBI::DatabaseError => e 213 false 214 end 215 216 # Reconnects to the database. 217 def reconnect! 218 begin 219 @connection.disconnect 220 @connection = DBI.connect(*@connection_options) 221 rescue DBI::DatabaseError => e 222 @logger.warn "#{adapter_name} automatic reconnection failed: #{e.message}" 223 end 224 end 225 226 198 227 199 228 def select_all(sql, name = nil)