Sha256: 61ed21b337e37267532114b73672a00e7e126934f3e2900a0bcee8bb16d29d2e

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

# Don't need to load native mysql adapter
$LOADED_FEATURES << "active_record/connection_adapters/mysql_adapter.rb"
$LOADED_FEATURES << "active_record/connection_adapters/mysql2_adapter.rb"

class ActiveRecord::Base
  class << self
    def mysql_connection(config)
      require "arjdbc/mysql"
      config[:port] ||= 3306
      options = (config[:options] ||= {})
      options['zeroDateTimeBehavior'] ||= 'convertToNull'
      options['jdbcCompliantTruncation'] ||= 'false'
      options['useUnicode'] ||= 'true'
      options['characterEncoding'] = config[:encoding] || 'utf8'
      config[:url] ||= "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
      config[:driver] ||= "com.mysql.jdbc.Driver"
      config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter
      connection = jdbc_connection(config)
      ::ArJdbc::MySQL.kill_cancel_timer(connection.raw_connection)
      connection
    end
    alias_method :jdbcmysql_connection, :mysql_connection
    alias_method :mysql2_connection, :mysql_connection
  end
end


Version data entries

14 entries across 14 versions & 4 rubygems

Version Path
intentmedia-activerecord-jdbc-adapter-1.1.1.1 lib/arjdbc/mysql/connection_methods.rb
c3-activerecord-jdbc-adapter-1.1.3.1 lib/arjdbc/mysql/connection_methods.rb
c3-activerecord-jdbc-adapter-1.1.3 lib/arjdbc/mysql/connection_methods.rb
jashmenn-activerecord-jdbc-adapter-1.2.0.0 lib/arjdbc/mysql/connection_methods.rb
jashmenn-activerecord-jdbc-adapter-1.2.0 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.1.3 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.1.2 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.1.1 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.1.0 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.0.3-java lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.0.2-java lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.0.1-java lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.0.0-java lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.0.0.beta2-java lib/arjdbc/mysql/connection_methods.rb