activerecord-jdbc-alt-adapter 52.4.0-java → 61.0.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.nvimlog +0 -0
- data/.travis.yml +63 -39
- data/Gemfile +11 -4
- data/README.md +55 -35
- data/Rakefile +1 -1
- data/Rakefile.jdbc +8 -1
- data/activerecord-jdbc-adapter.gemspec +6 -9
- data/activerecord-jdbc-alt-adapter.gemspec +9 -12
- data/lib/arel/visitors/postgresql_jdbc.rb +1 -1
- data/lib/arel/visitors/sqlserver.rb +49 -23
- data/lib/arjdbc/abstract/connection_management.rb +7 -0
- data/lib/arjdbc/abstract/core.rb +17 -23
- data/lib/arjdbc/abstract/database_statements.rb +30 -2
- data/lib/arjdbc/abstract/statement_cache.rb +2 -5
- data/lib/arjdbc/abstract/transaction_support.rb +22 -7
- data/lib/arjdbc/db2/column.rb +0 -39
- data/lib/arjdbc/derby/adapter.rb +1 -20
- data/lib/arjdbc/firebird/adapter.rb +0 -21
- data/lib/arjdbc/h2/adapter.rb +0 -15
- data/lib/arjdbc/hsqldb/adapter.rb +0 -14
- data/lib/arjdbc/informix/adapter.rb +0 -23
- data/lib/arjdbc/jdbc/adapter.rb +3 -1
- data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
- data/lib/arjdbc/jdbc/base_ext.rb +3 -1
- data/lib/arjdbc/jdbc/callbacks.rb +2 -0
- data/lib/arjdbc/jdbc/column.rb +2 -0
- data/lib/arjdbc/jdbc/connection.rb +2 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
- data/lib/arjdbc/jdbc/error.rb +2 -0
- data/lib/arjdbc/jdbc/extension.rb +2 -0
- data/lib/arjdbc/jdbc/java.rb +3 -1
- data/lib/arjdbc/jdbc/railtie.rb +3 -1
- data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
- data/lib/arjdbc/jdbc/type_cast.rb +2 -0
- data/lib/arjdbc/jdbc/type_converter.rb +2 -0
- data/lib/arjdbc/mssql.rb +3 -1
- data/lib/arjdbc/mssql/adapter.rb +114 -36
- data/lib/arjdbc/mssql/column.rb +19 -1
- data/lib/arjdbc/mssql/connection_methods.rb +10 -2
- data/lib/arjdbc/mssql/database_limits.rb +9 -0
- data/lib/arjdbc/mssql/database_statements.rb +44 -6
- data/lib/arjdbc/mssql/errors.rb +2 -0
- data/lib/arjdbc/mssql/explain_support.rb +3 -1
- data/lib/arjdbc/mssql/extensions/attribute_methods.rb +6 -2
- data/lib/arjdbc/mssql/extensions/calculations.rb +2 -0
- data/lib/arjdbc/mssql/quoting.rb +38 -0
- data/lib/arjdbc/mssql/schema_creation.rb +25 -3
- data/lib/arjdbc/mssql/schema_definitions.rb +10 -0
- data/lib/arjdbc/mssql/schema_dumper.rb +2 -0
- data/lib/arjdbc/mssql/schema_statements.rb +92 -22
- data/lib/arjdbc/mssql/transaction.rb +2 -0
- data/lib/arjdbc/mssql/types.rb +2 -0
- data/lib/arjdbc/mssql/types/binary_types.rb +2 -0
- data/lib/arjdbc/mssql/types/date_and_time_types.rb +2 -0
- data/lib/arjdbc/mssql/types/deprecated_types.rb +2 -0
- data/lib/arjdbc/mssql/types/numeric_types.rb +2 -0
- data/lib/arjdbc/mssql/types/string_types.rb +2 -0
- data/lib/arjdbc/mssql/utils.rb +2 -0
- data/lib/arjdbc/mysql/adapter.rb +59 -21
- data/lib/arjdbc/mysql/connection_methods.rb +6 -1
- data/lib/arjdbc/postgresql/adapter.rb +257 -219
- data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
- data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
- data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
- data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
- data/lib/arjdbc/postgresql/column.rb +6 -4
- data/lib/arjdbc/postgresql/connection_methods.rb +1 -0
- data/lib/arjdbc/postgresql/name.rb +2 -0
- data/lib/arjdbc/postgresql/oid_types.rb +7 -4
- data/lib/arjdbc/sqlite3/adapter.rb +266 -221
- data/lib/arjdbc/sqlite3/connection_methods.rb +26 -4
- data/lib/arjdbc/tasks/databases.rake +21 -13
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +126 -25
- data/lib/arjdbc/util/quoted_cache.rb +3 -1
- data/lib/arjdbc/util/serialized_attributes.rb +3 -1
- data/lib/arjdbc/util/table_copier.rb +3 -1
- data/lib/arjdbc/version.rb +3 -1
- data/pom.xml +4 -4
- data/rakelib/01-tomcat.rake +2 -2
- data/rakelib/rails.rake +1 -1
- data/src/java/arjdbc/ArJdbcModule.java +5 -5
- data/src/java/arjdbc/jdbc/DriverWrapper.java +1 -9
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +549 -691
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +88 -0
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +125 -53
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +97 -103
- data/src/java/arjdbc/util/DateTimeUtils.java +12 -4
- metadata +10 -18
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
ArJdbc::ConnectionMethods.module_eval do
|
|
3
3
|
def sqlite3_connection(config)
|
|
4
|
+
config = config.deep_dup
|
|
4
5
|
config[:adapter_spec] ||= ::ArJdbc::SQLite3
|
|
5
6
|
config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)
|
|
6
7
|
|
|
@@ -22,17 +23,37 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
|
22
23
|
raise
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
|
-
|
|
26
|
+
|
|
27
|
+
config[:properties] ||= {}
|
|
28
|
+
|
|
26
29
|
database = config[:database] # NOTE: "jdbc:sqlite::memory:" syntax is supported
|
|
27
30
|
config[:url] ||= "jdbc:sqlite:#{database == ':memory:' ? '' : database}"
|
|
28
31
|
config[:connection_alive_sql] ||= 'SELECT 1'
|
|
29
32
|
|
|
33
|
+
if config[:readonly]
|
|
34
|
+
# See
|
|
35
|
+
# * http://sqlite.org/c3ref/open.html
|
|
36
|
+
# * http://sqlite.org/c3ref/c_open_autoproxy.html
|
|
37
|
+
# => 0x01 = readonly, 0x40 = uri (default in JDBC)
|
|
38
|
+
config[:properties][:open_mode] = ::SQLite3::Constants::Open::READONLY | ::SQLite3::Constants::Open::URI
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
if config[:flags]
|
|
42
|
+
config[:properties][:open_mode] ||= 0
|
|
43
|
+
config[:properties][:open_mode] |= config[:flags]
|
|
44
|
+
|
|
45
|
+
# JDBC driver has an extra flag for it
|
|
46
|
+
if config[:flags] & ::SQLite3::Constants::Open::SHAREDCACHE != 0
|
|
47
|
+
config[:properties][:shared_cache] = true
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
30
51
|
timeout = config[:timeout]
|
|
31
52
|
if timeout && timeout.to_s !~ /\A\d+\Z/
|
|
32
53
|
raise TypeError.new "Timeout must be nil or a number (got: #{timeout})."
|
|
33
54
|
end
|
|
34
55
|
|
|
35
|
-
options =
|
|
56
|
+
options = config[:properties]
|
|
36
57
|
options['busy_timeout'] ||= timeout unless timeout.nil?
|
|
37
58
|
|
|
38
59
|
jdbc_connection(config)
|
|
@@ -50,8 +71,9 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
|
50
71
|
def parse_sqlite3_config!(config)
|
|
51
72
|
database = ( config[:database] ||= config[:dbfile] )
|
|
52
73
|
if ':memory:' != database
|
|
53
|
-
|
|
54
|
-
|
|
74
|
+
# make sure to have an absolute path. Ruby and Java don't agree on working directory
|
|
75
|
+
config[:database] = File.expand_path(database, defined?(Rails.root) ? Rails.root : nil)
|
|
76
|
+
dirname = File.dirname(config[:database])
|
|
55
77
|
Dir.mkdir(dirname) unless File.directory?(dirname)
|
|
56
78
|
end
|
|
57
79
|
end
|
|
@@ -5,34 +5,42 @@ module ActiveRecord::Tasks
|
|
|
5
5
|
DatabaseTasks.module_eval do
|
|
6
6
|
|
|
7
7
|
# @override patched to adapt jdbc configuration
|
|
8
|
-
def each_current_configuration(environment)
|
|
8
|
+
def each_current_configuration(environment, name = nil)
|
|
9
9
|
environments = [environment]
|
|
10
10
|
environments << 'test' if environment == 'development'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
environments.each do |env|
|
|
13
|
+
ActiveRecord::Base.configurations.configs_for(env_name: env).each do |db_config|
|
|
14
|
+
next if name && name != db_config.name
|
|
15
|
+
|
|
16
|
+
if db_config.database
|
|
17
|
+
yield adapt_jdbc_config(db_config), db_config.name, env
|
|
18
|
+
end
|
|
19
|
+
end
|
|
15
20
|
end
|
|
16
21
|
end
|
|
17
22
|
|
|
18
23
|
# @override patched to adapt jdbc configuration
|
|
19
24
|
def each_local_configuration
|
|
20
|
-
ActiveRecord::Base.configurations.
|
|
21
|
-
next unless
|
|
25
|
+
ActiveRecord::Base.configurations.configs_for.each do |db_config|
|
|
26
|
+
next unless db_config.database
|
|
22
27
|
|
|
23
|
-
if local_database?(
|
|
24
|
-
yield adapt_jdbc_config(
|
|
28
|
+
if local_database?(db_config)
|
|
29
|
+
yield adapt_jdbc_config(db_config)
|
|
25
30
|
else
|
|
26
|
-
$stderr.puts "This task only modifies local databases. #{
|
|
31
|
+
$stderr.puts "This task only modifies local databases. #{db_config.database} is on a remote host."
|
|
27
32
|
end
|
|
28
33
|
end
|
|
29
34
|
end
|
|
30
35
|
|
|
31
36
|
private
|
|
32
37
|
|
|
33
|
-
def adapt_jdbc_config(
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
def adapt_jdbc_config(db_config)
|
|
39
|
+
if db_config.adapter.start_with? 'jdbc'
|
|
40
|
+
config = db_config.configuration_hash.merge(adapter: db_config.adapter.sub(/^jdbc/, ''))
|
|
41
|
+
db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(db_config.env_name, db_config.name, config)
|
|
42
|
+
end
|
|
43
|
+
db_config
|
|
36
44
|
end
|
|
37
45
|
|
|
38
46
|
end
|
|
@@ -45,4 +53,4 @@ module ActiveRecord::Tasks
|
|
|
45
53
|
|
|
46
54
|
end if const_defined?(:MySQLDatabaseTasks)
|
|
47
55
|
|
|
48
|
-
end
|
|
56
|
+
end
|
|
@@ -1,46 +1,147 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'active_record/tasks/database_tasks'
|
|
2
4
|
|
|
3
5
|
module ArJdbc
|
|
4
|
-
module Tasks
|
|
5
|
-
class MSSQLDatabaseTasks
|
|
6
|
+
module Tasks # :nodoc:
|
|
7
|
+
class MSSQLDatabaseTasks # :nodoc:
|
|
8
|
+
delegate :connection, to: ActiveRecord::Base
|
|
9
|
+
delegate :establish_connection, to: ActiveRecord::Base
|
|
10
|
+
delegate :clear_active_connections!, to: ActiveRecord::Base
|
|
11
|
+
|
|
12
|
+
def self.using_database_configurations?
|
|
13
|
+
true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize(db_config)
|
|
17
|
+
@db_config = db_config
|
|
18
|
+
@configuration_hash = db_config.configuration_hash
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def create
|
|
22
|
+
establish_master_connection
|
|
23
|
+
connection.create_database(db_config.database, creation_options)
|
|
24
|
+
establish_connection(db_config)
|
|
25
|
+
rescue ActiveRecord::StatementInvalid => e
|
|
26
|
+
case e.message
|
|
27
|
+
when /database .* already exists/i
|
|
28
|
+
raise ActiveRecord::Tasks::DatabaseAlreadyExists
|
|
29
|
+
else
|
|
30
|
+
raise
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def drop
|
|
35
|
+
establish_master_connection
|
|
36
|
+
connection.drop_database(db_config.database)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def charset
|
|
40
|
+
connection.charset
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def collation
|
|
44
|
+
connection.collation
|
|
45
|
+
end
|
|
6
46
|
|
|
7
47
|
def purge
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
establish_connection(test)
|
|
12
|
-
connection.recreate_database(test_database)
|
|
48
|
+
clear_active_connections!
|
|
49
|
+
drop
|
|
50
|
+
create
|
|
13
51
|
end
|
|
14
52
|
|
|
15
|
-
def structure_dump(filename)
|
|
16
|
-
|
|
17
|
-
|
|
53
|
+
def structure_dump(filename, _extra_flags)
|
|
54
|
+
args = prepare_command_options
|
|
55
|
+
|
|
56
|
+
args.concat(["-f #{filename}"])
|
|
57
|
+
|
|
58
|
+
run_cmd('mssql-scripter', args, 'dumping')
|
|
18
59
|
end
|
|
19
60
|
|
|
20
|
-
def structure_load(filename)
|
|
21
|
-
|
|
22
|
-
|
|
61
|
+
def structure_load(filename, _extra_flags)
|
|
62
|
+
args = prepare_command_options
|
|
63
|
+
|
|
64
|
+
args.concat(["-i #{filename}"])
|
|
65
|
+
|
|
66
|
+
run_cmd('mssql-cli', args, 'loading')
|
|
23
67
|
end
|
|
24
68
|
|
|
25
69
|
private
|
|
26
70
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
71
|
+
attr_reader :db_config, :configuration_hash
|
|
72
|
+
|
|
73
|
+
def creation_options
|
|
74
|
+
{}.tap do |options|
|
|
75
|
+
options[:collation] = configuration_hash[:collation] if configuration_hash.include?(:collation)
|
|
76
|
+
|
|
77
|
+
# azure creation options
|
|
78
|
+
options[:azure_maxsize] = configuration_hash[:azure_maxsize] if configuration_hash.include?(:azure_maxsize)
|
|
79
|
+
options[:azure_edition] = configuration_hash[:azure_edition] if configuration_hash.include?(:azure_edition)
|
|
80
|
+
|
|
81
|
+
if configuration_hash.include?(:azure_service_objective)
|
|
82
|
+
options[:azure_service_objective] = configuration_hash[:azure_service_objective]
|
|
83
|
+
end
|
|
31
84
|
end
|
|
32
|
-
config
|
|
33
85
|
end
|
|
34
86
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
87
|
+
def establish_master_connection
|
|
88
|
+
establish_connection(configuration_hash.merge(database: 'master'))
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def prepare_command_options
|
|
92
|
+
{
|
|
93
|
+
server: '-S',
|
|
94
|
+
database: '-d',
|
|
95
|
+
username: '-U',
|
|
96
|
+
password: '-P'
|
|
97
|
+
}.map { |option, arg| "#{arg} #{config_for_cli[option]}" }
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def config_for_cli
|
|
101
|
+
{}.tap do |options|
|
|
102
|
+
if configuration_hash[:host].present? && configuration_hash[:port].present?
|
|
103
|
+
options[:server] = "#{configuration_hash[:host]},#{configuration_hash[:port]}"
|
|
104
|
+
elsif configuration_hash[:host].present?
|
|
105
|
+
options[:server] = configuration_hash[:host]
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
options[:database] = configuration_hash[:database] if configuration_hash[:database].present?
|
|
109
|
+
options[:username] = configuration_hash[:username] if configuration_hash[:username].present?
|
|
110
|
+
options[:password] = configuration_hash[:password] if configuration_hash[:password].present?
|
|
40
111
|
end
|
|
41
|
-
dup
|
|
42
112
|
end
|
|
43
113
|
|
|
114
|
+
def run_cmd(cmd, args, action)
|
|
115
|
+
fail run_cmd_error(cmd, args, action) unless Kernel.system(cmd, *args)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def run_cmd_error(cmd, args, action)
|
|
119
|
+
msg = +"failed to execute:\n"
|
|
120
|
+
msg << "#{cmd} #{args.join(' ')}\n\n"
|
|
121
|
+
msg << "Failed #{action} structure, please check the output above for any errors"
|
|
122
|
+
msg << " and make sure that `#{cmd}` is installed in your PATH and has proper permissions.\n\n"
|
|
123
|
+
msg
|
|
124
|
+
end
|
|
44
125
|
end
|
|
126
|
+
|
|
127
|
+
module DatabaseTasksMSSQL
|
|
128
|
+
extend ActiveSupport::Concern
|
|
129
|
+
|
|
130
|
+
module ClassMethods
|
|
131
|
+
|
|
132
|
+
def check_protected_environments!
|
|
133
|
+
super
|
|
134
|
+
rescue ActiveRecord::JDBCError => e
|
|
135
|
+
case e.message
|
|
136
|
+
when /cannot open database .* requested by the login/i
|
|
137
|
+
else
|
|
138
|
+
raise
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
ActiveRecord::Tasks::DatabaseTasks.send(:include, DatabaseTasksMSSQL)
|
|
45
146
|
end
|
|
46
147
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ArJdbc
|
|
2
4
|
module Util
|
|
3
5
|
# Gets included into `ActiveRecord::Base` to support sending LOB values
|
|
@@ -95,4 +97,4 @@ module ArJdbc
|
|
|
95
97
|
end
|
|
96
98
|
# @private only due backwards compatibility
|
|
97
99
|
SerializedAttributesHelper = Util::SerializedAttributes
|
|
98
|
-
end
|
|
100
|
+
end
|
data/lib/arjdbc/version.rb
CHANGED
data/pom.xml
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<url>http://github.com/jruby/activerecord-jdbc-adapter/wiki</url>
|
|
13
13
|
|
|
14
14
|
<properties>
|
|
15
|
-
<jruby.version>9.
|
|
15
|
+
<jruby.version>9.2.6.0</jruby.version>
|
|
16
16
|
</properties>
|
|
17
17
|
|
|
18
18
|
<issueManagement>
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
<dependency>
|
|
76
76
|
<groupId>org.postgresql</groupId>
|
|
77
77
|
<artifactId>postgresql</artifactId>
|
|
78
|
-
<version>42.1.4
|
|
78
|
+
<version>42.1.4</version>
|
|
79
79
|
</dependency>
|
|
80
80
|
</dependencies>
|
|
81
81
|
|
|
@@ -103,8 +103,8 @@
|
|
|
103
103
|
<artifactId>maven-compiler-plugin</artifactId>
|
|
104
104
|
<version>2.5.1</version>
|
|
105
105
|
<configuration>
|
|
106
|
-
<source>1.
|
|
107
|
-
<target>1.
|
|
106
|
+
<source>1.8</source>
|
|
107
|
+
<target>1.8</target>
|
|
108
108
|
</configuration>
|
|
109
109
|
</plugin>
|
|
110
110
|
</plugins>
|
data/rakelib/01-tomcat.rake
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
namespace :'tomcat-jndi' do # contains a FS JNDI impl (for tests)
|
|
2
2
|
|
|
3
|
-
TOMCAT_MAVEN_REPO = '
|
|
3
|
+
TOMCAT_MAVEN_REPO = 'https://repo1.maven.org/maven2/org/apache/tomcat'
|
|
4
4
|
TOMCAT_VERSION = '7.0.54'
|
|
5
5
|
|
|
6
6
|
DOWNLOAD_DIR = File.expand_path('../test/jars', File.dirname(__FILE__))
|
|
@@ -48,4 +48,4 @@ namespace :'tomcat-jndi' do # contains a FS JNDI impl (for tests)
|
|
|
48
48
|
rm jar_path if File.exist?(jar_path)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
end
|
|
51
|
+
end
|
data/rakelib/rails.rake
CHANGED
|
@@ -57,7 +57,7 @@ namespace :rails do
|
|
|
57
57
|
ruby_opts_string += " -C \"#{ar_path}\""
|
|
58
58
|
ruby_opts_string += " -rbundler/setup"
|
|
59
59
|
ruby_opts_string += " -rminitest -rminitest/excludes" unless ENV['NO_EXCLUDES'].eql?('true')
|
|
60
|
-
file_list = ENV["TEST"] ? FileList[ ENV["TEST"] ] : test_files_finder.call
|
|
60
|
+
file_list = ENV["TEST"] ? FileList[ ENV["TEST"].split(',') ] : test_files_finder.call
|
|
61
61
|
file_list_string = file_list.map { |fn| "\"#{fn}\"" }.join(' ')
|
|
62
62
|
# test_loader_code = "-e \"ARGV.each{|f| require f}\"" # :direct
|
|
63
63
|
option_list = ( ENV["TESTOPTS"] || ENV["TESTOPT"] || ENV["TEST_OPTS"] || '' )
|
|
@@ -151,7 +151,7 @@ public class ArJdbcModule {
|
|
|
151
151
|
throw newNativeException(runtime, e);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
return
|
|
154
|
+
return context.tru;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
/**
|
|
@@ -191,7 +191,7 @@ public class ArJdbcModule {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
// NOTE: probably useless - only to be useful for the pooled runtime mode when jar at WEB-INF/lib
|
|
194
|
-
static final Map<Ruby, Map<String, Boolean>> loadedDrivers = new WeakHashMap
|
|
194
|
+
static final Map<Ruby, Map<String, Boolean>> loadedDrivers = new WeakHashMap<>(8);
|
|
195
195
|
|
|
196
196
|
private static IRubyObject loadDriver(final ThreadContext context, final IRubyObject self,
|
|
197
197
|
final String constName) {
|
|
@@ -202,7 +202,7 @@ public class ArJdbcModule {
|
|
|
202
202
|
synchronized (ArJdbcModule.class) {
|
|
203
203
|
loadedMap = loadedDrivers.get(runtime);
|
|
204
204
|
if ( loadedMap == null ) {
|
|
205
|
-
loadedMap = new HashMap
|
|
205
|
+
loadedMap = new HashMap<>(4);
|
|
206
206
|
loadedDrivers.put(runtime, loadedMap);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
@@ -210,8 +210,8 @@ public class ArJdbcModule {
|
|
|
210
210
|
|
|
211
211
|
final Boolean driverLoaded = loadedMap.get(constName);
|
|
212
212
|
if ( driverLoaded != null ) {
|
|
213
|
-
if (
|
|
214
|
-
return
|
|
213
|
+
if (driverLoaded) return context.fals;
|
|
214
|
+
return context.nil;
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
try { // require 'jdbc/mysql'
|
|
@@ -60,15 +60,7 @@ public class DriverWrapper {
|
|
|
60
60
|
|
|
61
61
|
private Driver allocateDriver(final Class<? extends Driver> driverClass)
|
|
62
62
|
throws InstantiationException, IllegalAccessException {
|
|
63
|
-
|
|
64
|
-
return driverClass.newInstance();
|
|
65
|
-
}
|
|
66
|
-
catch (InstantiationException e) {
|
|
67
|
-
throw e;
|
|
68
|
-
}
|
|
69
|
-
catch (IllegalAccessException e) {
|
|
70
|
-
throw e;
|
|
71
|
-
}
|
|
63
|
+
return driverClass.newInstance();
|
|
72
64
|
}
|
|
73
65
|
|
|
74
66
|
protected static Class<? extends Driver> loadDriver(final Ruby runtime, final String name)
|