]> source.dussan.org Git - sonarqube.git/blob
a1267f6da01060bba5d290b8248c76ebe538a9d0
[sonarqube.git] /
1 # Don't need to load native mysql adapter
2 $LOADED_FEATURES << "active_record/connection_adapters/mysql_adapter.rb"
3 $LOADED_FEATURES << "active_record/connection_adapters/mysql2_adapter.rb"
4
5 class ActiveRecord::Base
6   class << self
7     def mysql_connection(config)
8       require "arjdbc/mysql"
9       config[:port] ||= 3306
10       options = (config[:options] ||= {})
11       options['zeroDateTimeBehavior'] ||= 'convertToNull'
12       options['jdbcCompliantTruncation'] ||= 'false'
13       options['useUnicode'] ||= 'true'
14       options['characterEncoding'] = config[:encoding] || 'utf8'
15       config[:url] ||= "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}"
16       config[:driver] ||= "com.mysql.jdbc.Driver"
17       config[:adapter_class] = ActiveRecord::ConnectionAdapters::MysqlAdapter
18       connection = jdbc_connection(config)
19       ::ArJdbc::MySQL.kill_cancel_timer(connection.raw_connection)
20       connection
21     end
22     alias_method :jdbcmysql_connection, :mysql_connection
23     alias_method :mysql2_connection, :mysql_connection
24   end
25 end
26
27