aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-12-02 01:19:18 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-12-02 01:19:18 +0000
commit3d0e3c92900ff3dd1ddef7c94c201698e71ca9d5 (patch)
tree685757d868f1df830a933f67db178411c61a1871 /activerecord/lib/active_record/connection_adapters/firebird_adapter.rb
parentc3612a23e6c83c7f5634d4379df3d9a08b538454 (diff)
downloadrails-3d0e3c92900ff3dd1ddef7c94c201698e71ca9d5.tar.gz
rails-3d0e3c92900ff3dd1ddef7c94c201698e71ca9d5.tar.bz2
rails-3d0e3c92900ff3dd1ddef7c94c201698e71ca9d5.zip
Firebird: active? and reconnect! methods for handling stale connections. References #428.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3205 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/firebird_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/firebird_adapter.rb25
1 files changed, 23 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb b/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb
index 110e774b5e..9bf047f0b8 100644
--- a/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/firebird_adapter.rb
@@ -31,9 +31,10 @@ module ActiveRecord
raise ArgumentError, "No database specified. Missing argument: database."
end
options = config[:charset] ? { CHARACTER_SET => config[:charset] } : {}
+ connection_params = [config[:username], config[:password], options]
db = FireRuby::Database.new_from_params(*config.values_at(:database, :host, :port, :service))
- connection = db.connect(config[:username], config[:password], options)
- ConnectionAdapters::FirebirdAdapter.new(connection, logger)
+ connection = db.connect(*connection_params)
+ ConnectionAdapters::FirebirdAdapter.new(connection, logger, connection_params)
end
end
@@ -240,6 +241,11 @@ module ActiveRecord
@@boolean_domain = { :true => 1, :false => 0 }
cattr_accessor :boolean_domain
+ def initialize(connection, logger, connection_params=nil)
+ super(connection, logger)
+ @connection_params = connection_params
+ end
+
def adapter_name # :nodoc:
'Firebird'
end
@@ -254,6 +260,7 @@ module ActiveRecord
"#{table_name}_seq"
end
+
# QUOTING ==================================================
def quote(value, column = nil) # :nodoc:
@@ -280,6 +287,19 @@ module ActiveRecord
quote(boolean_domain[:false])
end
+
+ # CONNECTION MANAGEMENT ====================================
+
+ def active?
+ not @connection.closed?
+ end
+
+ def reconnect!
+ @connection.close
+ @connection = @connection.database.connect(*@connection_params)
+ end
+
+
# DATABASE STATEMENTS ======================================
def select_all(sql, name = nil) # :nodoc:
@@ -340,6 +360,7 @@ module ActiveRecord
FireRuby::Generator.new(sequence_name, @connection).next(1)
end
+
# SCHEMA STATEMENTS ========================================
def columns(table_name, name = nil) # :nodoc: