Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update FrontBase adapter to check binding version. Closes #4920. [mla…

…ster@metavillage.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4304 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit f26e9b68612823f00962366368ee19beb567d44f 1 parent bb87517
Marcel Molina authored
View
2  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.]
View
29 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 @@ def frontbase_connection(config) # :nodoc:
# 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 @@ def simplified_type(field_type, type_name,limit)
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)
Please sign in to comment.
Something went wrong with that request. Please try again.