aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 3f826edfe2..8619da8c5b 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -57,12 +57,14 @@ module ActiveRecord
# Is this connection alive and ready for queries?
def active?
- # TODO: postgres-pr doesn't have PGconn#status.
if @connection.respond_to?(:status)
- @connection.status != PGconn::CONNECTION_BAD
+ @connection.status == PGconn::CONNECTION_OK
else
+ @connection.query 'SELECT 1'
true
end
+ rescue PGError
+ false
end
# Close then reopen the connection.