Sha256: c1998abd5569b99b00abd423db2c4624d254b991b83a5c855125b4a6352d3def

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 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
      config[:adapter_spec] = ::ArJdbc::MySQL
      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

12 entries across 12 versions & 4 rubygems

Version Path
cmoran92-activerecord-jdbc-adapter-1.2.1.2 lib/arjdbc/mysql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.5 lib/arjdbc/mysql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.4 lib/arjdbc/mysql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.3 lib/arjdbc/mysql/connection_methods.rb
tgbyte-activerecord-jdbc-adapter-1.2.2.2 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.2.2.1 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-onsite-1.2.2 lib/arjdbc/mysql/connection_methods.rb
cmoran92-activerecord-jdbc-adapter-1.2.1.1 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.2.2 lib/arjdbc/mysql/connection_methods.rb
cmoran92-activerecord-jdbc-adapter-1.2.1 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.2.1 lib/arjdbc/mysql/connection_methods.rb
activerecord-jdbc-adapter-1.2.0 lib/arjdbc/mysql/connection_methods.rb