activerecord-jdbc-adapter 52.8-java → 60.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.travis.yml +58 -37
  4. data/Gemfile +9 -2
  5. data/README.md +25 -9
  6. data/Rakefile +1 -1
  7. data/Rakefile.jdbc +8 -1
  8. data/activerecord-jdbc-adapter.gemspec +5 -8
  9. data/lib/arjdbc/abstract/connection_management.rb +7 -0
  10. data/lib/arjdbc/abstract/core.rb +16 -23
  11. data/lib/arjdbc/abstract/database_statements.rb +26 -2
  12. data/lib/arjdbc/abstract/statement_cache.rb +2 -5
  13. data/lib/arjdbc/abstract/transaction_support.rb +5 -3
  14. data/lib/arjdbc/db2/column.rb +0 -39
  15. data/lib/arjdbc/derby/adapter.rb +1 -20
  16. data/lib/arjdbc/firebird/adapter.rb +0 -21
  17. data/lib/arjdbc/h2/adapter.rb +0 -15
  18. data/lib/arjdbc/hsqldb/adapter.rb +0 -14
  19. data/lib/arjdbc/informix/adapter.rb +0 -23
  20. data/lib/arjdbc/jdbc/adapter.rb +3 -1
  21. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  22. data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
  23. data/lib/arjdbc/jdbc/base_ext.rb +3 -1
  24. data/lib/arjdbc/jdbc/callbacks.rb +2 -0
  25. data/lib/arjdbc/jdbc/column.rb +2 -0
  26. data/lib/arjdbc/jdbc/connection.rb +2 -0
  27. data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
  28. data/lib/arjdbc/jdbc/error.rb +2 -0
  29. data/lib/arjdbc/jdbc/extension.rb +2 -0
  30. data/lib/arjdbc/jdbc/java.rb +3 -1
  31. data/lib/arjdbc/jdbc/railtie.rb +3 -1
  32. data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
  33. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
  34. data/lib/arjdbc/jdbc/type_cast.rb +2 -0
  35. data/lib/arjdbc/jdbc/type_converter.rb +2 -0
  36. data/lib/arjdbc/mysql/adapter.rb +47 -18
  37. data/lib/arjdbc/mysql/connection_methods.rb +0 -1
  38. data/lib/arjdbc/postgresql/adapter.rb +220 -213
  39. data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
  40. data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
  41. data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
  42. data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
  43. data/lib/arjdbc/postgresql/column.rb +6 -4
  44. data/lib/arjdbc/postgresql/connection_methods.rb +0 -1
  45. data/lib/arjdbc/postgresql/name.rb +2 -0
  46. data/lib/arjdbc/postgresql/oid_types.rb +2 -0
  47. data/lib/arjdbc/sqlite3/adapter.rb +175 -180
  48. data/lib/arjdbc/sqlite3/connection_methods.rb +15 -5
  49. data/lib/arjdbc/tasks/databases.rake +13 -10
  50. data/lib/arjdbc/util/quoted_cache.rb +3 -1
  51. data/lib/arjdbc/util/serialized_attributes.rb +3 -1
  52. data/lib/arjdbc/util/table_copier.rb +3 -1
  53. data/lib/arjdbc/version.rb +1 -1
  54. data/pom.xml +4 -4
  55. data/rakelib/01-tomcat.rake +2 -2
  56. data/rakelib/rails.rake +1 -1
  57. data/src/java/arjdbc/ArJdbcModule.java +5 -5
  58. data/src/java/arjdbc/jdbc/DriverWrapper.java +1 -9
  59. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +434 -701
  60. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +0 -51
  61. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
  62. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +31 -24
  63. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +94 -99
  64. 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 = ( config[:properties] ||= {} )
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
- config[:database] = File.expand_path(database, Rails.root) if defined?(Rails.root)
55
- dirname = File.dirname(database)
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
- configurations = ActiveRecord::Base.configurations.values_at(*environments)
13
- configurations.compact.each do |config|
14
- yield adapt_jdbc_config(config) unless config['database'].blank?
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.each_value do |config|
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
  # Caches table and column name (quoted) outcomes.
@@ -57,4 +59,4 @@ module ArJdbc
57
59
 
58
60
  end
59
61
  end
60
- end
62
+ 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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ArJdbc
2
4
  module Util
3
5
  module TableCopier
@@ -107,4 +109,4 @@ module ArJdbc
107
109
  end
108
110
  # @private @deprecated backwards compatibility
109
111
  MissingFunctionalityHelper = Util::TableCopier
110
- end
112
+ end
@@ -1,3 +1,3 @@
1
1
  module ArJdbc
2
- VERSION = '52.8'
2
+ VERSION = '60.0'
3
3
  end
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.1.6.0</jruby.version>
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.jre7</version>
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.7</source>
107
- <target>1.7</target>
106
+ <source>1.8</source>
107
+ <target>1.8</target>
108
108
  </configuration>
109
109
  </plugin>
110
110
  </plugins>
@@ -1,6 +1,6 @@
1
1
  namespace :'tomcat-jndi' do # contains a FS JNDI impl (for tests)
2
2
 
3
- TOMCAT_MAVEN_REPO = 'https://repo1.maven.org/maven2/org/apache/tomcat'
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"].split(',') ] : test_files_finder.call
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 runtime.getTrue();
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<Ruby, Map<String, Boolean>>(8);
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<String, Boolean>(4);
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 ( driverLoaded.booleanValue() ) return runtime.getFalse();
214
- return runtime.getNil();
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
- try {
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)