Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3195

Show
Ignore:
Timestamp:
11/28/05 21:46:34 (3 years ago)
Author:
bitsweat
Message:

PostgreSQL: active? compatibility with the pure-Ruby driver. Still need to move connect into the adapter since postgres-pr doesn't support #reset. References #428.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r3194 r3195  
    11*SVN* 
    22 
    3 * MySQL: active? compatibility with the pure-Ruby driver.  #428 [Jeremy Kemper] 
     3* MySQL and PostgreSQL: active? compatibility with the pure-Ruby driver.  #428 [Jeremy Kemper] 
    44 
    55* Oracle: active? check pings the database rather than testing the last command status.  #428 [Michael Schoen] 
  • trunk/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb

    r3165 r3195  
    5858      # Is this connection alive and ready for queries? 
    5959      def active? 
    60         # TODO: postgres-pr doesn't have PGconn#status. 
    6160        if @connection.respond_to?(:status) 
    62           @connection.status != PGconn::CONNECTION_BAD 
     61          @connection.status == PGconn::CONNECTION_OK 
    6362        else 
     63          @connection.query 'SELECT 1' 
    6464          true 
    6565        end 
     66      rescue PGError 
     67        false 
    6668      end 
    6769