lib/og/store/mysql.rb in og-0.19.0 vs lib/og/store/mysql.rb in og-0.20.0

- old
+ new

@@ -1,10 +1,17 @@ begin require 'mysql' rescue Object => ex Logger.error 'Ruby-Mysql bindings are not installed!' - Logger.error ex + Logger.error 'Trying to uses the pure-Ruby binding included in Og' + begin + # Attempt to use the included pure ruby version. + require 'vendor/mysql' + require 'vendor/mysql411' + rescue Object => ex + Logger.error ex + end end require 'og/store/sql' # Customize the standard mysql resultset to make @@ -93,9 +100,18 @@ options[:address] || 'localhost', options[:user], options[:password], options[:name] ) + + # You should set recconect to true to avoid MySQL has + # gone away errors. + + if @conn.respond_to? :reconnect + options[:reconnect] = true unless options.has_key?(:reconnect) + @conn.reconnect = options[:reconnect] + end + rescue => ex if ex.errno == 1049 # database does not exist. Logger.info "Database '#{options[:name]}' not found!" self.class.create(options) retry