activerecord-jdbc-adapter 60.1-java → 60.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/lib/arjdbc/postgresql/adapter.rb +22 -3
- data/lib/arjdbc/postgresql/oid_types.rb +1 -1
- data/lib/arjdbc/sqlite3/adapter.rb +20 -7
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/01-tomcat.rake +2 -2
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +20 -14
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd9e15552e3b9f6f65c66efeee8c74f9b97866ce5f6529ca39b20272d5b30523
|
4
|
+
data.tar.gz: 0aa62947429e9c330b35331f5bb77af6d551d746ce726ca7854018a0ce8fd29e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1852d21daa1321cc311d33362d605dcac55c691dd5912755727e5f3809fdcf3cb487b4eb4384d98eb05f9464e30b0dddf003ef7ca297bc94cf02446e45620c6
|
7
|
+
data.tar.gz: 9221932463a324cdf0058d382d86ebc3b90c91fc5a00d3fd4d0bbe51bb8bd0ad03ff9457c0a7cf80ec531ce534de875a3bffdc25b4a4cec773b253df12b85774
|
data/.travis.yml
CHANGED
@@ -69,6 +69,9 @@ matrix:
|
|
69
69
|
- addons:
|
70
70
|
postgresql: "10"
|
71
71
|
env: DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
|
72
|
+
- addons:
|
73
|
+
postgresql: "10"
|
74
|
+
env: DB=postgresql PREPARED_STATEMENTS=true JRUBY_OPTS=-J-Duser.timezone=America/Detroit
|
72
75
|
- addons:
|
73
76
|
postgresql: "9.4"
|
74
77
|
env: DB=postgresql PREPARED_STATEMENTS=true
|
@@ -303,6 +303,10 @@ module ArJdbc
|
|
303
303
|
@has_pg_hint_plan
|
304
304
|
end
|
305
305
|
|
306
|
+
def supports_common_table_expressions?
|
307
|
+
true
|
308
|
+
end
|
309
|
+
|
306
310
|
def supports_lazy_transactions?
|
307
311
|
true
|
308
312
|
end
|
@@ -379,13 +383,23 @@ module ArJdbc
|
|
379
383
|
end
|
380
384
|
end
|
381
385
|
|
386
|
+
def execute_batch(statements, name = nil)
|
387
|
+
if statements.is_a? Array
|
388
|
+
execute(combine_multi_statements(statements), name)
|
389
|
+
else
|
390
|
+
execute(statements, name)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
382
394
|
def explain(arel, binds = [])
|
383
395
|
sql, binds = to_sql_and_binds(arel, binds)
|
384
396
|
ActiveRecord::ConnectionAdapters::PostgreSQL::ExplainPrettyPrinter.new.pp(exec_query("EXPLAIN #{sql}", 'EXPLAIN', binds))
|
385
397
|
end
|
386
398
|
|
387
399
|
# from ActiveRecord::ConnectionAdapters::PostgreSQL::DatabaseStatements
|
388
|
-
READ_QUERY = ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
|
400
|
+
READ_QUERY = ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
|
401
|
+
:begin, :commit, :explain, :select, :set, :show, :release, :savepoint, :rollback, :with
|
402
|
+
) # :nodoc:
|
389
403
|
private_constant :READ_QUERY
|
390
404
|
|
391
405
|
def write_query?(sql) # :nodoc:
|
@@ -435,7 +449,12 @@ module ArJdbc
|
|
435
449
|
end
|
436
450
|
|
437
451
|
def build_truncate_statements(*table_names)
|
438
|
-
"TRUNCATE TABLE #{table_names.map(&method(:quote_table_name)).join(", ")}"
|
452
|
+
["TRUNCATE TABLE #{table_names.flatten.map(&method(:quote_table_name)).join(", ")}"]
|
453
|
+
end
|
454
|
+
|
455
|
+
def truncate(table_name, name = nil)
|
456
|
+
ActiveRecord::Base.clear_query_caches_for_current_thread if @query_cache_enabled
|
457
|
+
execute("TRUNCATE TABLE #{quote_table_name(table_name)}", name)
|
439
458
|
end
|
440
459
|
|
441
460
|
def all_schemas
|
@@ -493,7 +512,7 @@ module ArJdbc
|
|
493
512
|
alias_method :quote_schema_name, :quote_column_name
|
494
513
|
|
495
514
|
# Need to clear the cache even though the AR adapter doesn't for some reason
|
496
|
-
def remove_column(table_name, column_name, type = nil, options
|
515
|
+
def remove_column(table_name, column_name, type = nil, **options)
|
497
516
|
super
|
498
517
|
clear_cache!
|
499
518
|
end
|
@@ -213,7 +213,7 @@ module ArJdbc
|
|
213
213
|
if oid
|
214
214
|
if oid.is_a? Numeric || oid.match(/^\d+$/)
|
215
215
|
# numeric OID
|
216
|
-
query += "WHERE t.oid
|
216
|
+
query += "WHERE t.oid = %s" % oid
|
217
217
|
|
218
218
|
elsif m = oid.match(/"?(\w+)"?\."?(\w+)"?/)
|
219
219
|
# namespace and type name
|
@@ -97,6 +97,10 @@ module ArJdbc
|
|
97
97
|
true
|
98
98
|
end
|
99
99
|
|
100
|
+
def supports_common_table_expressions?
|
101
|
+
database_version >= "3.8.3"
|
102
|
+
end
|
103
|
+
|
100
104
|
def supports_insert_on_conflict?
|
101
105
|
database_version >= "3.24.0"
|
102
106
|
end
|
@@ -154,7 +158,9 @@ module ArJdbc
|
|
154
158
|
# DATABASE STATEMENTS ======================================
|
155
159
|
#++
|
156
160
|
|
157
|
-
READ_QUERY = ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
|
161
|
+
READ_QUERY = ActiveRecord::ConnectionAdapters::AbstractAdapter.build_read_query_regexp(
|
162
|
+
:begin, :commit, :explain, :select, :pragma, :release, :savepoint, :rollback, :with
|
163
|
+
) # :nodoc:
|
158
164
|
private_constant :READ_QUERY
|
159
165
|
|
160
166
|
def write_query?(sql) # :nodoc:
|
@@ -223,7 +229,7 @@ module ArJdbc
|
|
223
229
|
end
|
224
230
|
end
|
225
231
|
|
226
|
-
def remove_column(table_name, column_name, type = nil, options
|
232
|
+
def remove_column(table_name, column_name, type = nil, **options) #:nodoc:
|
227
233
|
alter_table(table_name) do |definition|
|
228
234
|
definition.remove_column column_name
|
229
235
|
definition.foreign_keys.delete_if do |_, fk_options|
|
@@ -317,11 +323,17 @@ module ArJdbc
|
|
317
323
|
SQLite3Adapter::Version.new(query_value("SELECT sqlite_version(*)"))
|
318
324
|
end
|
319
325
|
|
326
|
+
def build_truncate_statement(table_name)
|
327
|
+
"DELETE FROM #{quote_table_name(table_name)}"
|
328
|
+
end
|
329
|
+
|
320
330
|
def build_truncate_statements(*table_names)
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
331
|
+
table_names.flatten.map { |table_name| build_truncate_statement table_name }
|
332
|
+
end
|
333
|
+
|
334
|
+
def truncate(table_name, name = nil)
|
335
|
+
ActiveRecord::Base.clear_query_caches_for_current_thread if @query_cache_enabled
|
336
|
+
execute(build_truncate_statement(table_name), name)
|
325
337
|
end
|
326
338
|
|
327
339
|
def check_version
|
@@ -352,7 +364,8 @@ module ArJdbc
|
|
352
364
|
# See: https://www.sqlite.org/lang_altertable.html
|
353
365
|
# SQLite has an additional restriction on the ALTER TABLE statement
|
354
366
|
def invalid_alter_table_type?(type, options)
|
355
|
-
type.to_sym == :primary_key || options[:primary_key]
|
367
|
+
type.to_sym == :primary_key || options[:primary_key] ||
|
368
|
+
options[:null] == false && options[:default].nil?
|
356
369
|
end
|
357
370
|
|
358
371
|
def alter_table(table_name, foreign_keys = foreign_keys(table_name), **options)
|
data/lib/arjdbc/version.rb
CHANGED
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
|
@@ -36,26 +36,18 @@ import java.io.ByteArrayInputStream;
|
|
36
36
|
import java.lang.StringBuilder;
|
37
37
|
import java.lang.reflect.InvocationTargetException;
|
38
38
|
import java.math.BigDecimal;
|
39
|
-
import java.sql
|
40
|
-
import java.sql.
|
41
|
-
import java.
|
42
|
-
import java.sql.ResultSet;
|
43
|
-
import java.sql.ResultSetMetaData;
|
44
|
-
import java.sql.SQLException;
|
45
|
-
import java.sql.Timestamp;
|
46
|
-
import java.sql.Types;
|
47
|
-
import java.util.ArrayList;
|
48
|
-
import java.util.Collections;
|
49
|
-
import java.util.HashMap;
|
50
|
-
import java.util.Map;
|
51
|
-
import java.util.UUID;
|
39
|
+
import java.sql.*;
|
40
|
+
import java.sql.Date;
|
41
|
+
import java.util.*;
|
52
42
|
import java.util.regex.Pattern;
|
53
43
|
import java.util.regex.Matcher;
|
54
44
|
|
45
|
+
import org.joda.time.DateTime;
|
55
46
|
import org.jruby.*;
|
56
47
|
import org.jruby.anno.JRubyMethod;
|
57
48
|
import org.jruby.exceptions.RaiseException;
|
58
49
|
import org.jruby.ext.bigdecimal.RubyBigDecimal;
|
50
|
+
import org.jruby.ext.date.RubyDate;
|
59
51
|
import org.jruby.javasupport.JavaUtil;
|
60
52
|
import org.jruby.runtime.ObjectAllocator;
|
61
53
|
import org.jruby.runtime.ThreadContext;
|
@@ -115,6 +107,7 @@ public class PostgreSQLRubyJdbcConnection extends arjdbc.jdbc.RubyJdbcConnection
|
|
115
107
|
|
116
108
|
// Used to wipe trailing 0's from points (3.0, 5.6) -> (3, 5.6)
|
117
109
|
private static final Pattern pointCleanerPattern = Pattern.compile("\\.0\\b");
|
110
|
+
private static final TimeZone TZ_DEFAULT = TimeZone.getDefault();
|
118
111
|
|
119
112
|
private RubyClass resultClass;
|
120
113
|
private RubyHash typeMap = null;
|
@@ -386,7 +379,20 @@ public class PostgreSQLRubyJdbcConnection extends arjdbc.jdbc.RubyJdbcConnection
|
|
386
379
|
}
|
387
380
|
}
|
388
381
|
|
389
|
-
|
382
|
+
if ( ! "Date".equals(value.getMetaClass().getName()) && value.respondsTo("to_date") ) {
|
383
|
+
value = value.callMethod(context, "to_date");
|
384
|
+
}
|
385
|
+
|
386
|
+
if (value instanceof RubyDate) {
|
387
|
+
RubyDate rubyDate = (RubyDate) value;
|
388
|
+
DateTime dt = rubyDate.getDateTime();
|
389
|
+
// pgjdbc needs adjustment for default JVM timezone
|
390
|
+
statement.setDate(index, new Date(dt.getMillis() - TZ_DEFAULT.getOffset(dt.getMillis())));
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
|
394
|
+
// NOTE: assuming Date#to_s does right ...
|
395
|
+
statement.setDate(index, Date.valueOf(value.toString()));
|
390
396
|
}
|
391
397
|
|
392
398
|
@Override
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-jdbc-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '60.
|
4
|
+
version: '60.2'
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Nick Sieger, Ola Bini, Karol Bucek and JRuby contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -17,8 +17,8 @@ dependencies:
|
|
17
17
|
- !ruby/object:Gem::Version
|
18
18
|
version: 6.0.0
|
19
19
|
name: activerecord
|
20
|
-
prerelease: false
|
21
20
|
type: :runtime
|
21
|
+
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
@@ -230,8 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
230
|
- !ruby/object:Gem::Version
|
231
231
|
version: '0'
|
232
232
|
requirements: []
|
233
|
-
|
234
|
-
rubygems_version: 2.7.10
|
233
|
+
rubygems_version: 3.0.6
|
235
234
|
signing_key:
|
236
235
|
specification_version: 4
|
237
236
|
summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.
|