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
@@ -28,11 +28,6 @@ module ArJdbc
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcColumn#column_types
|
32
|
-
def self.column_selector
|
33
|
-
[ /informix/i, lambda { |cfg, column| column.extend(ColumnMethods) } ]
|
34
|
-
end
|
35
|
-
|
36
31
|
JdbcConnection = ::ActiveRecord::ConnectionAdapters::InformixJdbcConnection
|
37
32
|
|
38
33
|
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#jdbc_connection_class
|
@@ -45,20 +40,6 @@ module ArJdbc
|
|
45
40
|
::ActiveRecord::ConnectionAdapters::InformixColumn
|
46
41
|
end
|
47
42
|
|
48
|
-
module ColumnMethods
|
49
|
-
|
50
|
-
private
|
51
|
-
# TODO: Test all Informix column types.
|
52
|
-
def simplified_type(field_type)
|
53
|
-
if field_type =~ /serial/i
|
54
|
-
:primary_key
|
55
|
-
else
|
56
|
-
super
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
43
|
def modify_types(types)
|
63
44
|
super(types)
|
64
45
|
types[:primary_key] = "SERIAL PRIMARY KEY"
|
@@ -152,10 +133,6 @@ module ArJdbc
|
|
152
133
|
end # module ::ArJdbc
|
153
134
|
|
154
135
|
module ActiveRecord::ConnectionAdapters
|
155
|
-
class InformixColumn < JdbcColumn
|
156
|
-
include ::ArJdbc::Informix::ColumnMethods
|
157
|
-
end
|
158
|
-
|
159
136
|
class InformixAdapter < JdbcAdapter
|
160
137
|
include ::ArJdbc::Informix
|
161
138
|
end
|
data/lib/arjdbc/jdbc/adapter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_record/version'
|
2
4
|
require 'active_record/connection_adapters/abstract_adapter'
|
3
5
|
|
@@ -94,7 +96,7 @@ module ActiveRecord
|
|
94
96
|
nil
|
95
97
|
end
|
96
98
|
|
97
|
-
ADAPTER_NAME = 'JDBC'
|
99
|
+
ADAPTER_NAME = 'JDBC'
|
98
100
|
|
99
101
|
# @return [String] the 'JDBC' adapter name.
|
100
102
|
def adapter_name
|
Binary file
|
data/lib/arjdbc/jdbc/base_ext.rb
CHANGED
data/lib/arjdbc/jdbc/column.rb
CHANGED
data/lib/arjdbc/jdbc/error.rb
CHANGED
data/lib/arjdbc/jdbc/java.rb
CHANGED
data/lib/arjdbc/jdbc/railtie.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'arjdbc/util/serialized_attributes'
|
2
4
|
|
3
|
-
ArJdbc.deprecate "require 'arjdbc/util/serialized_attributes' instead of 'arjdbc/jdbc/serialized_attributes_helper'"
|
5
|
+
ArJdbc.deprecate "require 'arjdbc/util/serialized_attributes' instead of 'arjdbc/jdbc/serialized_attributes_helper'"
|
data/lib/arjdbc/mysql/adapter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
ArJdbc.load_java_part :MySQL
|
2
4
|
|
3
5
|
require 'bigdecimal'
|
@@ -19,7 +21,7 @@ module ActiveRecord
|
|
19
21
|
remove_const(:Mysql2Adapter) if const_defined?(:Mysql2Adapter)
|
20
22
|
|
21
23
|
class Mysql2Adapter < AbstractMysqlAdapter
|
22
|
-
ADAPTER_NAME = 'Mysql2'
|
24
|
+
ADAPTER_NAME = 'Mysql2'
|
23
25
|
|
24
26
|
include Jdbc::ConnectionPoolCallbacks
|
25
27
|
|
@@ -32,21 +34,30 @@ module ActiveRecord
|
|
32
34
|
include ArJdbc::MySQL
|
33
35
|
|
34
36
|
def initialize(connection, logger, connection_parameters, config)
|
35
|
-
# workaround to skip version check on JNDI to be lazy, dummy version is high enough for Rails 5.0 - 6.0
|
36
|
-
is_jndi = ::ActiveRecord::ConnectionAdapters::JdbcConnection.jndi_config?(config)
|
37
|
-
@version = '8.1.5' if is_jndi
|
38
|
-
|
39
37
|
super
|
40
38
|
|
41
|
-
# set to nil to have it lazy-load the real value when required
|
42
|
-
@version = nil if is_jndi
|
43
|
-
|
44
39
|
@prepared_statements = false unless config.key?(:prepared_statements)
|
45
40
|
# configure_connection taken care of at ArJdbc::Abstract::Core
|
46
41
|
end
|
47
42
|
|
43
|
+
def self.database_exists?(config)
|
44
|
+
conn = ActiveRecord::Base.mysql2_connection(config)
|
45
|
+
conn && conn.really_valid?
|
46
|
+
rescue ActiveRecord::NoDatabaseError
|
47
|
+
false
|
48
|
+
ensure
|
49
|
+
conn.disconnect! if conn
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_version
|
53
|
+
# for JNDI, don't check version as the whole connection should be lazy
|
54
|
+
return if ::ActiveRecord::ConnectionAdapters::JdbcConnection.jndi_config?(config)
|
55
|
+
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
48
59
|
def supports_json?
|
49
|
-
!mariadb? &&
|
60
|
+
!mariadb? && database_version >= '5.7.8'
|
50
61
|
end
|
51
62
|
|
52
63
|
def supports_comments?
|
@@ -61,6 +72,10 @@ module ActiveRecord
|
|
61
72
|
true
|
62
73
|
end
|
63
74
|
|
75
|
+
def supports_lazy_transactions?
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
64
79
|
def supports_transaction_isolation?
|
65
80
|
true
|
66
81
|
end
|
@@ -71,6 +86,16 @@ module ActiveRecord
|
|
71
86
|
|
72
87
|
# HELPER METHODS ===========================================
|
73
88
|
|
89
|
+
# from MySQL::DatabaseStatements
|
90
|
+
READ_QUERY = ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
|
91
|
+
:begin, :commit, :explain, :select, :set, :show, :release, :savepoint, :rollback, :describe, :desc
|
92
|
+
) # :nodoc:
|
93
|
+
private_constant :READ_QUERY
|
94
|
+
|
95
|
+
def write_query?(sql) # :nodoc:
|
96
|
+
!READ_QUERY.match?(sql)
|
97
|
+
end
|
98
|
+
|
74
99
|
# Reloading the type map in abstract/statement_cache.rb blows up postgres
|
75
100
|
def clear_cache!
|
76
101
|
reload_type_map
|
@@ -136,7 +161,13 @@ module ActiveRecord
|
|
136
161
|
private
|
137
162
|
|
138
163
|
# e.g. "5.7.20-0ubuntu0.16.04.1"
|
139
|
-
def full_version
|
164
|
+
def full_version
|
165
|
+
schema_cache.database_version.full_version_string
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_full_version
|
169
|
+
@full_version ||= @connection.full_version
|
170
|
+
end
|
140
171
|
|
141
172
|
def jdbc_connection_class(spec)
|
142
173
|
::ActiveRecord::ConnectionAdapters::MySQLJdbcConnection
|
@@ -152,15 +183,13 @@ module ActiveRecord
|
|
152
183
|
end
|
153
184
|
|
154
185
|
# FIXME: optimize insert_fixtures_set by using JDBC Statement.addBatch()/executeBatch()
|
155
|
-
def combine_multi_statements(total_sql)
|
156
|
-
total_sql
|
157
|
-
end
|
158
|
-
|
159
|
-
def with_multi_statements
|
160
|
-
yield
|
161
|
-
end
|
162
186
|
|
163
|
-
def
|
187
|
+
def combine_multi_statements(total_sql)
|
188
|
+
if total_sql.length == 1
|
189
|
+
total_sql.first
|
190
|
+
else
|
191
|
+
total_sql
|
192
|
+
end
|
164
193
|
end
|
165
194
|
end
|
166
195
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
ArJdbc::ConnectionMethods.module_eval do
|
3
3
|
def mysql_connection(config)
|
4
|
-
config = config.deep_dup
|
5
4
|
# NOTE: this isn't "really" necessary but Rails (in tests) assumes being able to :
|
6
5
|
# ActiveRecord::Base.mysql2_connection ActiveRecord::Base.configurations['arunit'].merge(database: ...)
|
7
6
|
config = symbolize_keys_if_necessary(config)
|