diff options
author | Marcel Molina <marcel@vernix.org> | 2006-04-28 20:04:47 +0000 |
---|---|---|
committer | Marcel Molina <marcel@vernix.org> | 2006-04-28 20:04:47 +0000 |
commit | f26e9b68612823f00962366368ee19beb567d44f (patch) | |
tree | 5e6f4e265bed6d7479339c802d9ae39f9c120fe7 /activerecord/lib/active_record/connection_adapters | |
parent | bb875172e2812488439fd5f8e7ff9fa1646ea77c (diff) | |
download | rails-f26e9b68612823f00962366368ee19beb567d44f.tar.gz rails-f26e9b68612823f00962366368ee19beb567d44f.tar.bz2 rails-f26e9b68612823f00962366368ee19beb567d44f.zip |
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
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb b/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb index 3b323193e8..7a6386bd7d 100644 --- a/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb @@ -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' @@ -27,12 +26,22 @@ module ActiveRecord # Turn off colorization since it makes tail/less output difficult self.colorize_logging = false + + 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 - require 'frontbase' + 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 - end + end end module ConnectionAdapters @@ -223,6 +232,18 @@ module ActiveRecord end 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) |