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 | |
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
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/frontbase_adapter.rb | 29 |
2 files changed, 27 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 4ec5db2140..3a9fc110d6 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -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.] 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) |