activerecord-jdbc-adapter 52.8-java → 60.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/.travis.yml +58 -37
- data/Gemfile +9 -2
- data/README.md +25 -9
- data/Rakefile +1 -1
- data/Rakefile.jdbc +8 -1
- data/activerecord-jdbc-adapter.gemspec +5 -8
- data/lib/arjdbc/abstract/connection_management.rb +7 -0
- data/lib/arjdbc/abstract/core.rb +16 -23
- data/lib/arjdbc/abstract/database_statements.rb +26 -2
- data/lib/arjdbc/abstract/statement_cache.rb +2 -5
- data/lib/arjdbc/abstract/transaction_support.rb +5 -3
- 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_java.jar +0 -0
- 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/mysql/adapter.rb +47 -18
- data/lib/arjdbc/mysql/connection_methods.rb +0 -1
- data/lib/arjdbc/postgresql/adapter.rb +220 -213
- 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 +0 -1
- data/lib/arjdbc/postgresql/name.rb +2 -0
- data/lib/arjdbc/postgresql/oid_types.rb +2 -0
- data/lib/arjdbc/sqlite3/adapter.rb +175 -180
- data/lib/arjdbc/sqlite3/connection_methods.rb +15 -5
- data/lib/arjdbc/tasks/databases.rake +13 -10
- 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 +1 -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 +434 -701
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +0 -51
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +31 -24
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +94 -99
- metadata +7 -9
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
ArJdbc::ConnectionMethods.module_eval do
|
3
3
|
def sqlite3_connection(config)
|
4
|
-
config = config.deep_dup
|
5
4
|
config[:adapter_spec] ||= ::ArJdbc::SQLite3
|
6
5
|
config[:adapter_class] = ActiveRecord::ConnectionAdapters::SQLite3Adapter unless config.key?(:adapter_class)
|
7
6
|
|
@@ -23,17 +22,27 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
23
22
|
raise
|
24
23
|
end
|
25
24
|
end
|
26
|
-
|
25
|
+
|
26
|
+
config[:properties] ||= {}
|
27
|
+
|
27
28
|
database = config[:database] # NOTE: "jdbc:sqlite::memory:" syntax is supported
|
28
29
|
config[:url] ||= "jdbc:sqlite:#{database == ':memory:' ? '' : database}"
|
29
30
|
config[:connection_alive_sql] ||= 'SELECT 1'
|
30
31
|
|
32
|
+
if config[:readonly]
|
33
|
+
# See
|
34
|
+
# * http://sqlite.org/c3ref/open.html
|
35
|
+
# * http://sqlite.org/c3ref/c_open_autoproxy.html
|
36
|
+
# => 0x01 = readonly, 0x40 = uri (default in JDBC)
|
37
|
+
config[:properties][:open_mode] = 0x01 | 0x40
|
38
|
+
end
|
39
|
+
|
31
40
|
timeout = config[:timeout]
|
32
41
|
if timeout && timeout.to_s !~ /\A\d+\Z/
|
33
42
|
raise TypeError.new "Timeout must be nil or a number (got: #{timeout})."
|
34
43
|
end
|
35
44
|
|
36
|
-
options =
|
45
|
+
options = config[:properties]
|
37
46
|
options['busy_timeout'] ||= timeout unless timeout.nil?
|
38
47
|
|
39
48
|
jdbc_connection(config)
|
@@ -51,8 +60,9 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
51
60
|
def parse_sqlite3_config!(config)
|
52
61
|
database = ( config[:database] ||= config[:dbfile] )
|
53
62
|
if ':memory:' != database
|
54
|
-
|
55
|
-
|
63
|
+
# make sure to have an absolute path. Ruby and Java don't agree on working directory
|
64
|
+
config[:database] = File.expand_path(database, defined?(Rails.root) ? Rails.root : nil)
|
65
|
+
dirname = File.dirname(config[:database])
|
56
66
|
Dir.mkdir(dirname) unless File.directory?(dirname)
|
57
67
|
end
|
58
68
|
end
|
@@ -5,25 +5,28 @@ 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, spec_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 spec_name && spec_name != db_config.spec_name
|
15
|
+
|
16
|
+
yield adapt_jdbc_config(db_config.config), db_config.spec_name, env unless db_config.config['database'].blank?
|
17
|
+
end
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
21
|
# @override patched to adapt jdbc configuration
|
19
22
|
def each_local_configuration
|
20
|
-
ActiveRecord::Base.configurations.
|
21
|
-
next unless config['database']
|
23
|
+
ActiveRecord::Base.configurations.configs_for.each do |db_config|
|
24
|
+
next unless db_config.config['database']
|
22
25
|
|
23
|
-
if local_database?(config)
|
24
|
-
yield adapt_jdbc_config(config)
|
26
|
+
if local_database?(db_config.config)
|
27
|
+
yield adapt_jdbc_config(db_config.config)
|
25
28
|
else
|
26
|
-
$stderr.puts "This task only modifies local databases. #{config['database']} is on a remote host."
|
29
|
+
$stderr.puts "This task only modifies local databases. #{db_config.config['database']} is on a remote host."
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
@@ -45,4 +48,4 @@ module ActiveRecord::Tasks
|
|
45
48
|
|
46
49
|
end if const_defined?(:MySQLDatabaseTasks)
|
47
50
|
|
48
|
-
end
|
51
|
+
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 = 'http://repo2.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
@@ -51,7 +51,7 @@ namespace :rails do
|
|
51
51
|
ruby_opts_string += " -C \"#{ar_path}\""
|
52
52
|
ruby_opts_string += " -rbundler/setup"
|
53
53
|
ruby_opts_string += " -rminitest -rminitest/excludes" unless ENV['NO_EXCLUDES'].eql?('true')
|
54
|
-
file_list = ENV["TEST"] ? FileList[ ENV["TEST"]
|
54
|
+
file_list = ENV["TEST"] ? FileList[ ENV["TEST"] ] : test_files_finder.call
|
55
55
|
file_list_string = file_list.map { |fn| "\"#{fn}\"" }.join(' ')
|
56
56
|
# test_loader_code = "-e \"ARGV.each{|f| require f}\"" # :direct
|
57
57
|
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)
|