Update FrontBase adapter to check binding version. Closes #4920. [mlaster@metavillage.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4304 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Marcel Molina 2006-04-28 20:04:47 +00:00
parent bb875172e2
commit f26e9b6861
2 changed files with 27 additions and 4 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Update FrontBase adapter to check binding version. Closes #4920. [mlaster@metavillage.com]
* New Frontbase connections don't start in auto-commit mode. Closes #4922. [mlaster@metavillage.com]
* When grouping, use the appropriate option key. [Marcel Molina Jr.]

View File

@ -1,5 +1,4 @@
# Requires FrontBase Ruby bindings from:
# svn://rubyforge.org/var/svn/frontbase-rails/trunk/ruby-frontbase
# Requires FrontBase Ruby bindings (gem install ruby-frontbase)
require 'active_record/connection_adapters/abstract_adapter'
@ -28,7 +27,17 @@ module ActiveRecord
# Turn off colorization since it makes tail/less output difficult
self.colorize_logging = false
require 'frontbase'
require_library_or_gem 'frontbase' unless self.class.const_defined? :FBSQL_Connect
# Check bindings version
version = "0.0.0"
version = FBSQL_Connect::FB_BINDINGS_VERSION if defined? FBSQL_Connect::FB_BINDINGS_VERSION
if ActiveRecord::ConnectionAdapters::FrontBaseAdapter.compare_versions(version,"1.0.0") == -1
raise AdapterNotFound,
'The FrontBase adapter requires ruby-frontbase version 1.0.0 or greater; you appear ' <<
"to be running an older version (#{version}) -- please update ruby-frontbase (gem install ruby-frontbase)."
end
connection = FBSQL_Connect.connect(host, port, database, username, password, dbpassword, session_name)
ConnectionAdapters::FrontBaseAdapter.new(connection, logger, [host, port, database, username, password, dbpassword, session_name], config)
end
@ -224,6 +233,18 @@ module ActiveRecord
class FrontBaseAdapter < AbstractAdapter
class << self
def compare_versions(v1, v2)
v1_seg = v1.split(".")
v2_seg = v2.split(".")
0.upto([v1_seg.length,v2_seg.length].min) do |i|
step = (v1_seg[i].to_i <=> v2_seg[i].to_i)
return step unless step == 0
end
return v1_seg.length <=> v2_seg.length
end
end
def initialize(connection, logger, connection_options, config)
super(connection, logger)
@connection_options, @config = connection_options, config