activerecord-jdbc-adapter 50.8-java → 51.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -2
- data/.travis.yml +26 -51
- data/Gemfile +3 -1
- data/README.md +9 -11
- data/Rakefile +15 -78
- data/activerecord-jdbc-adapter.gemspec +2 -2
- data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/arjdbc/abstract/core.rb +4 -12
- data/lib/arjdbc/abstract/database_statements.rb +4 -10
- data/lib/arjdbc/abstract/statement_cache.rb +4 -4
- data/lib/arjdbc/abstract/transaction_support.rb +2 -9
- data/lib/arjdbc/jdbc.rb +4 -0
- data/lib/arjdbc/jdbc/column.rb +11 -5
- data/lib/arjdbc/jdbc/connection_methods.rb +9 -2
- data/lib/arjdbc/jdbc/error.rb +1 -1
- data/lib/arjdbc/jdbc/jdbc.rake +4 -0
- data/lib/arjdbc/mssql.rb +7 -0
- data/lib/arjdbc/mssql/adapter.rb +804 -0
- data/lib/arjdbc/mssql/column.rb +200 -0
- data/lib/arjdbc/mssql/connection_methods.rb +79 -0
- data/lib/arjdbc/mssql/explain_support.rb +99 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +231 -0
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/types.rb +343 -0
- data/lib/arjdbc/mssql/utils.rb +82 -0
- data/lib/arjdbc/mysql/adapter.rb +14 -11
- data/lib/arjdbc/mysql/connection_methods.rb +9 -18
- data/lib/arjdbc/postgresql/adapter.rb +108 -59
- data/lib/arjdbc/postgresql/column.rb +3 -6
- data/lib/arjdbc/postgresql/connection_methods.rb +3 -12
- data/lib/arjdbc/postgresql/oid_types.rb +14 -93
- data/lib/arjdbc/sqlite3/adapter.rb +171 -140
- data/lib/arjdbc/sqlite3/connection_methods.rb +1 -2
- data/lib/arjdbc/tasks/database_tasks.rb +36 -16
- data/lib/arjdbc/tasks/databases.rake +75 -32
- data/lib/arjdbc/tasks/databases3.rake +215 -0
- data/lib/arjdbc/tasks/databases4.rake +39 -0
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/01-tomcat.rake +2 -2
- data/rakelib/02-test.rake +3 -0
- data/rakelib/compile.rake +70 -0
- data/rakelib/db.rake +7 -21
- data/rakelib/rails.rake +4 -5
- data/src/java/arjdbc/ArJdbcModule.java +15 -5
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +2 -2
- data/src/java/arjdbc/jdbc/ConnectionFactory.java +87 -0
- data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +1 -0
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +41 -120
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +14 -310
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +2 -2
- data/src/java/arjdbc/postgresql/ByteaUtils.java +1 -0
- data/src/java/arjdbc/postgresql/PgResultSetMetaDataWrapper.java +23 -0
- data/src/java/arjdbc/postgresql/PostgreSQLResult.java +13 -21
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +46 -41
- data/src/java/arjdbc/util/DateTimeUtils.java +5 -141
- data/src/java/arjdbc/util/QuotingUtils.java +7 -6
- data/src/java/arjdbc/util/StringHelper.java +20 -6
- metadata +25 -16
- data/src/java/arjdbc/jdbc/RubyConnectionFactory.java +0 -61
- data/src/java/arjdbc/postgresql/PgDateTimeUtils.java +0 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a171f4269e41c768fcbfaaccbf2f6f2c2df051ae
|
4
|
+
data.tar.gz: ec6aee76c700cfec4c7cfb3ffd64de135149a159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c51149881eb9da030aad612f6df71cb2bff662ed6288cacb14aa7ddd61e42c42039ca0b425ed7df06345b71319f417bf4bc3e23f112113ff8403827127c075ef
|
7
|
+
data.tar.gz: ac52a7288354ab3ee6871fa149eff7cc7d74242e8950d46d43d9e034a511d665bdc61e7de44aa5491ecdb6ce07b3da36f88b55e0bdcb0973158432cef1c34470
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,27 +1,9 @@
|
|
1
|
+
language: ruby
|
1
2
|
sudo: false
|
2
|
-
|
3
|
-
|
4
|
-
services:
|
5
|
-
- mysql
|
6
|
-
addons:
|
7
|
-
postgresql: 9.4
|
8
|
-
|
3
|
+
bundler_args: --without development
|
4
|
+
script: bundle exec rake ${TEST_PREFIX}test_$DB
|
9
5
|
before_install:
|
10
6
|
- unset _JAVA_OPTIONS
|
11
|
-
- rvm @default,@global do gem uninstall bundler -a -x -I || true
|
12
|
-
- gem install bundler -v "~>1.17.3"
|
13
|
-
install:
|
14
|
-
- bundle install --retry 3 --without development
|
15
|
-
# to fix this issue: https://travis-ci.community/t/mariadb-10-1-fails-to-install-on-xenial/3151/3
|
16
|
-
- mysql -u root -e 'CREATE USER IF NOT EXISTS travis@localhost; GRANT ALL ON *.* TO travis@localhost;' || true
|
17
|
-
|
18
|
-
language: ruby
|
19
|
-
rvm:
|
20
|
-
- jruby-9.1.16.0
|
21
|
-
jdk:
|
22
|
-
- openjdk8
|
23
|
-
|
24
|
-
script: bundle exec rake ${TEST_PREFIX}test_$DB
|
25
7
|
before_script:
|
26
8
|
- echo "JAVA_OPTS=$JAVA_OPTS"
|
27
9
|
- export JRUBY_OPTS="-J-Xms64M -J-Xmx1024M"
|
@@ -39,15 +21,18 @@ before_script:
|
|
39
21
|
mysql -e "grant all privileges on activerecord_unittest.* to rails@localhost;" && \
|
40
22
|
mysql -e "grant all privileges on activerecord_unittest2.* to rails@localhost;" && \
|
41
23
|
mysql -e "grant all privileges on inexistent_activerecord_unittest.* to rails@localhost;" && \
|
42
|
-
mysql -e "CREATE DATABASE activerecord_unittest
|
43
|
-
mysql -e "CREATE DATABASE activerecord_unittest2
|
24
|
+
mysql -e "CREATE DATABASE activerecord_unittest;" && \
|
25
|
+
mysql -e "CREATE DATABASE activerecord_unittest2;" \
|
44
26
|
|| true
|
45
27
|
- |
|
46
28
|
[ "$DB" == "postgresql" ] && [ "$TEST_PREFIX" == "rails:" ] && \
|
47
29
|
psql -c "create database activerecord_unittest;" -U postgres && \
|
48
30
|
psql -c "create database activerecord_unittest2;" -U postgres \
|
49
31
|
|| true
|
50
|
-
|
32
|
+
rvm:
|
33
|
+
- jruby-9.1.16.0
|
34
|
+
jdk:
|
35
|
+
- openjdk8
|
51
36
|
env:
|
52
37
|
- DB=mysql2 PREPARED_STATEMENTS=false
|
53
38
|
- DB=mysql2 PREPARED_STATEMENTS=true
|
@@ -58,29 +43,19 @@ env:
|
|
58
43
|
- DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
|
59
44
|
- DB=sqlite3 PREPARED_STATEMENTS=false
|
60
45
|
- DB=sqlite3 PREPARED_STATEMENTS=true
|
61
|
-
|
62
|
-
|
46
|
+
#- DB=jndi PREPARED_STATEMENTS=false
|
47
|
+
#- DB=jndi PREPARED_STATEMENTS=true
|
48
|
+
branches:
|
49
|
+
only:
|
50
|
+
- master
|
51
|
+
- /.*-stable$/
|
52
|
+
- /^test-.*/
|
53
|
+
- /maintenance|support/
|
54
|
+
- /.*dev$/
|
63
55
|
matrix:
|
64
56
|
allow_failures:
|
65
57
|
- rvm: jruby-head
|
66
58
|
include:
|
67
|
-
# jruby-9.2
|
68
|
-
- rvm: jruby-9.2.6.0
|
69
|
-
env: DB=mysql2
|
70
|
-
- rvm: jruby-9.2.6.0
|
71
|
-
env: DB=postgresql
|
72
|
-
- rvm: jruby-9.2.6.0
|
73
|
-
env: DB=sqlite3
|
74
|
-
# jruby-9.2 + Java 11
|
75
|
-
- rvm: jruby-9.2.6.0
|
76
|
-
env: DB=mysql2
|
77
|
-
jdk: openjdk11
|
78
|
-
- rvm: jruby-9.2.6.0
|
79
|
-
env: DB=postgresql
|
80
|
-
jdk: openjdk11
|
81
|
-
- rvm: jruby-9.2.6.0
|
82
|
-
env: DB=sqlite3
|
83
|
-
jdk: openjdk11
|
84
59
|
# jruby-head
|
85
60
|
- rvm: jruby-head
|
86
61
|
env: DB=mysql2
|
@@ -90,15 +65,15 @@ matrix:
|
|
90
65
|
env: DB=sqlite3
|
91
66
|
# testing against MariaDB
|
92
67
|
- addons:
|
93
|
-
mariadb: 10.
|
68
|
+
mariadb: '10.0'
|
94
69
|
env: DB=mariadb PREPARED_STATEMENTS=false
|
95
70
|
- addons:
|
96
|
-
mariadb: 10.
|
71
|
+
mariadb: '10.1'
|
97
72
|
env: DB=mariadb PREPARED_STATEMENTS=true
|
98
73
|
# Rails test-suite :
|
99
|
-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.
|
100
|
-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.
|
101
|
-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.
|
102
|
-
- env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.
|
103
|
-
- env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.
|
104
|
-
- env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="v5.
|
74
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.6" # PS off by default
|
75
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.6" PREPARED_STATEMENTS=true
|
76
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.6" DRIVER=MariaDB
|
77
|
+
- env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.1.6" # PS on by default
|
78
|
+
- env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.1.6" PREPARED_STATEMENTS=false
|
79
|
+
- env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="v5.1.6"
|
data/Gemfile
CHANGED
@@ -48,7 +48,6 @@ group :test do
|
|
48
48
|
gem 'mocha', '~> 1.2', require: false # Rails has '~> 0.14'
|
49
49
|
|
50
50
|
gem 'bcrypt', '~> 3.1.11', require: false
|
51
|
-
gem 'builder', require: false
|
52
51
|
end
|
53
52
|
|
54
53
|
group :rails do
|
@@ -61,6 +60,9 @@ group :rails do
|
|
61
60
|
gem 'benchmark-ips', require: nil
|
62
61
|
end
|
63
62
|
|
63
|
+
# AR expects this for testing xml in postgres (maybe others?)
|
64
|
+
gem 'builder', require: nil
|
65
|
+
|
64
66
|
gem 'erubis', require: nil # "~> 2.7.0"
|
65
67
|
# NOTE: due rails/activerecord/test/cases/connection_management_test.rb
|
66
68
|
gem 'rack', require: nil
|
data/README.md
CHANGED
@@ -5,16 +5,15 @@
|
|
5
5
|
ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails'
|
6
6
|
*ActiveRecord* component that can be used with [JRuby][0].
|
7
7
|
ActiveRecord-JDBC-Adapter provides full or nearly full support for:
|
8
|
-
**MySQL**, **PostgreSQL**, **SQLite3
|
8
|
+
**MySQL**, **PostgreSQL**, **SQLite3**. In the near future there are plans to
|
9
|
+
add support **MSSQL**. Unless we get more contributions we will not be going
|
10
|
+
beyond these four adapters. Note that the amount of work needed to get
|
11
|
+
another adapter is not huge but the amount of testing required to make sure
|
12
|
+
that adapter continues to work is not something we can do with the resources
|
13
|
+
we currently have.
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
the amount of testing required to make sure that adapter continues to work
|
13
|
-
is not something we can do with the resources we currently have.
|
14
|
-
|
15
|
-
- for **Oracle** database users you are encouraged to use
|
16
|
-
https://github.com/rsim/oracle-enhanced
|
17
|
-
- **MSSQL** adapter's gem parts reside in a [separate repository][8]
|
15
|
+
For Oracle database users you are encouraged to use
|
16
|
+
https://github.com/rsim/oracle-enhanced.
|
18
17
|
|
19
18
|
Version **50.x** supports Rails version 5.0.x and it lives on branch 50-stable.
|
20
19
|
Version **51.x** supports Rails version 5.1.x and is currently on master until
|
@@ -33,7 +32,6 @@ adapters are available:
|
|
33
32
|
- MySQL (`activerecord-jdbcmysql-adapter`)
|
34
33
|
- PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
|
35
34
|
- SQLite3 (`activerecord-jdbcsqlite3-adapter`)
|
36
|
-
- MSSQL (`activerecord-jdbcsqlserver-adapter`)
|
37
35
|
|
38
36
|
2. If you're generating a new Rails application, use the following command:
|
39
37
|
|
@@ -168,4 +166,4 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
|
|
168
166
|
[5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
|
169
167
|
[6]: https://webchat.freenode.net/?channels=#jruby
|
170
168
|
[7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
|
171
|
-
[8]: https://github.com/jruby/activerecord-
|
169
|
+
[8]: https://github.com/jruby/activerecord-jdbc-adapter/wiki/Migrating-from-1.2.x-to-1.3.0
|
data/Rakefile
CHANGED
@@ -1,29 +1,3 @@
|
|
1
|
-
# Common usage
|
2
|
-
#
|
3
|
-
# rake build:adapters - to build all specific adapter gems and the base gem
|
4
|
-
# rake release:do - build:adapters + git tag + push gems
|
5
|
-
#
|
6
|
-
# Environment variables used by this Rakefile:
|
7
|
-
#
|
8
|
-
# INCLUDE_JAR_IN_GEM [default task - false, other taks - true]:
|
9
|
-
# Note: This is something you should not normally have to set.
|
10
|
-
# For local development we always will end up including the jar file
|
11
|
-
# in any task which generates our main gem. The wrinkle to this
|
12
|
-
# is when we do a custom github link in bundler:
|
13
|
-
#
|
14
|
-
# gem 'ar-jdbc', github: '...'
|
15
|
-
#
|
16
|
-
# Because we stopped committing a .jar file for every change and so when
|
17
|
-
# we include a gem like this it clones the repository and does a default
|
18
|
-
# build in rake. This in turn will end up forcing a compile to generate
|
19
|
-
# that jar (similar to how c-extensions compile at the time of install).
|
20
|
-
# For shipped gems we do include the jar so that people do not require
|
21
|
-
# this compile step.
|
22
|
-
#
|
23
|
-
# NOOP [release:do - false]
|
24
|
-
#
|
25
|
-
# No commands or gem pushing during a release.
|
26
|
-
|
27
1
|
require 'rake/clean'
|
28
2
|
|
29
3
|
CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
|
@@ -64,8 +38,7 @@ rake = lambda { |task| ruby "-S", "rake", task }
|
|
64
38
|
|
65
39
|
desc "Build #{gem_name} gem into the pkg directory."
|
66
40
|
task :build => :jar do
|
67
|
-
|
68
|
-
sh("INCLUDE_JAR_IN_GEM=#{include_jar} gem build -V '#{gemspec_path}'") do
|
41
|
+
sh("RELEASE=#{ENV['RELEASE']} gem build -V '#{gemspec_path}'") do
|
69
42
|
gem_path = built_gem_path.call
|
70
43
|
file_name = File.basename(gem_path)
|
71
44
|
FileUtils.mkdir_p(File.join(base_dir, 'pkg'))
|
@@ -85,6 +58,7 @@ end
|
|
85
58
|
|
86
59
|
desc "Releasing AR-JDBC gems (use NOOP=true to disable gem pushing)"
|
87
60
|
task 'release:do' do
|
61
|
+
ENV['RELEASE'] = 'true' # so that .gemspec is built with adapter_java.jar
|
88
62
|
Rake::Task['build'].invoke
|
89
63
|
Rake::Task['build:adapters'].invoke
|
90
64
|
|
@@ -262,43 +236,23 @@ if defined? JRUBY_VERSION
|
|
262
236
|
end
|
263
237
|
|
264
238
|
classpath = []
|
265
|
-
[ 'java.class.path', 'sun.boot.class.path' ].
|
266
|
-
classpath +=
|
239
|
+
[ 'java.class.path', 'sun.boot.class.path' ].each do |key|
|
240
|
+
classpath += ENV_JAVA[key].split(File::PATH_SEPARATOR).find_all { |jar| jar =~ /jruby/i }
|
267
241
|
end
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
error "Cannot build activerecord-jdbc with jruby-complete"
|
273
|
-
end
|
274
|
-
classpath << File.join(libdir, 'jruby.jar')
|
275
|
-
end
|
276
|
-
|
242
|
+
|
243
|
+
#classpath += ENV_JAVA['java.class.path'].split(File::PATH_SEPARATOR)
|
244
|
+
#classpath += ENV_JAVA['sun.boot.class.path'].split(File::PATH_SEPARATOR)
|
245
|
+
|
277
246
|
classpath += driver_jars
|
278
247
|
classpath = classpath.compact.join(File::PATH_SEPARATOR)
|
279
248
|
|
280
249
|
source_files = FileList[ 'src/java/**/*.java' ]
|
281
250
|
|
282
|
-
|
283
|
-
begin
|
284
|
-
require 'arjdbc/version'
|
285
|
-
rescue LoadError
|
286
|
-
path = File.expand_path('lib', File.dirname(__FILE__))
|
287
|
-
unless $LOAD_PATH.include?(path)
|
288
|
-
$LOAD_PATH << path; retry
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
gem_version = Gem::Version.create(ArJdbc::VERSION)
|
293
|
-
if gem_version.segments.last == 'DEV'
|
294
|
-
gem_version.segments[0...-1] # 50.0.DEV -> 50.0
|
295
|
-
else
|
296
|
-
gem_version.segments.dup
|
297
|
-
end
|
298
|
-
end
|
251
|
+
require 'tmpdir'
|
299
252
|
|
300
|
-
|
301
|
-
# Cross-platform way of finding an executable in the $PATH.
|
253
|
+
Dir.mktmpdir do |classes_dir|
|
254
|
+
# Cross-platform way of finding an executable in the $PATH.
|
255
|
+
# Thanks to @mislav
|
302
256
|
which = lambda do |cmd|
|
303
257
|
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
304
258
|
ENV['PATH'].split(File::PATH_SEPARATOR).map do |path|
|
@@ -322,24 +276,7 @@ if defined? JRUBY_VERSION
|
|
322
276
|
# avoid environment variable expansion using backslash
|
323
277
|
# class_files.gsub!('$', '\$') unless windows?
|
324
278
|
# args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
|
325
|
-
|
326
|
-
if ENV['INCLUDE_JAR_IN_GEM'] == 'true'; require 'tempfile'
|
327
|
-
manifest = "Built-Time: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')}\n"
|
328
|
-
manifest += "Built-JRuby: #{JRUBY_VERSION}\n"
|
329
|
-
manifest += "Specification-Title: ActiveRecord-JDBC\n"
|
330
|
-
manifest += "Specification-Vendor: JRuby\n"
|
331
|
-
manifest += "Specification-Version: #{version.call[0].to_s.split('').join('.')}\n" # AR VERSION (52 -> 5.2)
|
332
|
-
manifest += "Implementation-Vendor: The JRuby Team\n"
|
333
|
-
manifest += "Implementation-Version: #{version.call.join('.')}\n"
|
334
|
-
manifest = Tempfile.new('MANIFEST').tap { |f| f << manifest; f.close }.path
|
335
|
-
end
|
336
|
-
|
337
|
-
args = []; opts = '-cf'
|
338
|
-
if manifest
|
339
|
-
opts = "#{opts}m"
|
340
|
-
args = [ "#{manifest}" ]
|
341
|
-
end
|
342
|
-
args += [ '-C', "#{classes_dir}/ ." ]
|
279
|
+
args = [ '-C', "#{classes_dir}/ ." ] # args = class_files
|
343
280
|
|
344
281
|
jar_path = jar_file
|
345
282
|
if ext_lib_dir = ENV['RUBYLIBDIR']
|
@@ -349,7 +286,7 @@ if defined? JRUBY_VERSION
|
|
349
286
|
unless jar = which.call('jar')
|
350
287
|
warn "could not find jar tool, please make sure it's on the PATH"
|
351
288
|
end
|
352
|
-
sh("#{jar}
|
289
|
+
sh("#{jar} cf #{jar_path} #{args.join(' ')}") do |ok|
|
353
290
|
raise 'could not build .jar extension - packaging failure' unless ok
|
354
291
|
end
|
355
292
|
cp jar_path, jar_file if ext_lib_dir # NOTE: hopefully RG won't mind?!
|
@@ -357,6 +294,6 @@ if defined? JRUBY_VERSION
|
|
357
294
|
end
|
358
295
|
else
|
359
296
|
task :jar do
|
360
|
-
|
297
|
+
puts "please run `rake jar' under JRuby to re-compile the native (Java) extension"
|
361
298
|
end
|
362
299
|
end
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
|
|
27
27
|
reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
|
28
28
|
gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
|
29
29
|
|
30
|
-
if ENV['
|
30
|
+
if ENV['RELEASE'] != 'true' # @see Rakefile
|
31
31
|
gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
|
32
32
|
|
33
33
|
#gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
|
@@ -44,7 +44,7 @@ Gem::Specification.new do |gem|
|
|
44
44
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
45
45
|
gem.test_files = gem.files.grep(%r{^test/})
|
46
46
|
|
47
|
-
gem.add_dependency 'activerecord', '~> 5.
|
47
|
+
gem.add_dependency 'activerecord', '~> 5.1.0'
|
48
48
|
|
49
49
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
50
50
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'arjdbc/mssql'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'arjdbc/mssql'
|
data/lib/arjdbc/abstract/core.rb
CHANGED
@@ -22,7 +22,7 @@ module ArJdbc
|
|
22
22
|
|
23
23
|
connection.configure_connection # will call us (maybe)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
# Retrieve the raw `java.sql.Connection` object.
|
27
27
|
# The unwrap parameter is useful if an attempt to unwrap a pooled (JNDI)
|
28
28
|
# connection should be made - to really return the 'native' JDBC object.
|
@@ -47,6 +47,8 @@ module ArJdbc
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def translate_exception(e, message)
|
50
|
+
# override in derived class
|
51
|
+
|
50
52
|
# we shall not translate native "Java" exceptions as they might
|
51
53
|
# swallow an ArJdbc / driver bug into an AR::StatementInvalid !
|
52
54
|
return e if e.is_a?(Java::JavaLang::Throwable)
|
@@ -54,21 +56,11 @@ module ArJdbc
|
|
54
56
|
case e
|
55
57
|
when SystemExit, SignalException, NoMemoryError then e
|
56
58
|
when ActiveModel::RangeError, TypeError, RuntimeError then e
|
57
|
-
else
|
59
|
+
else ActiveRecord::StatementInvalid.new(message)
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
|
-
def extract_raw_bind_values(binds)
|
62
|
-
binds.map(&:value_for_database)
|
63
|
-
end
|
64
63
|
|
65
|
-
# this version of log() automatically fills type_casted_binds from binds if necessary
|
66
|
-
def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
|
67
|
-
if binds.any? && (type_casted_binds.nil? || type_casted_binds.empty?)
|
68
|
-
type_casted_binds = ->{ extract_raw_bind_values(binds) }
|
69
|
-
end
|
70
|
-
super
|
71
|
-
end
|
72
64
|
end
|
73
65
|
end
|
74
66
|
end
|
@@ -10,13 +10,11 @@ module ArJdbc
|
|
10
10
|
NO_BINDS = [].freeze
|
11
11
|
|
12
12
|
def exec_insert(sql, name = nil, binds = NO_BINDS, pk = nil, sequence_name = nil)
|
13
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
14
|
-
|
15
13
|
if without_prepared_statement?(binds)
|
16
|
-
log(sql, name) { @connection.
|
14
|
+
log(sql, name) { @connection.execute_insert(sql) }
|
17
15
|
else
|
18
16
|
log(sql, name, binds) do
|
19
|
-
@connection.
|
17
|
+
@connection.execute_insert(sql, binds)
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
@@ -24,22 +22,18 @@ module ArJdbc
|
|
24
22
|
# It appears that at this point (AR 5.0) "prepare" should only ever be true
|
25
23
|
# if prepared statements are enabled
|
26
24
|
def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false)
|
27
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
28
|
-
|
29
25
|
if without_prepared_statement?(binds)
|
30
26
|
log(sql, name) { @connection.execute_query(sql) }
|
31
27
|
else
|
32
28
|
log(sql, name, binds) do
|
33
|
-
#
|
34
|
-
cached_statement = fetch_cached_statement(sql) if prepare &&
|
29
|
+
# It seems that #supports_statement_cache? is defined but isn't checked before setting "prepare" (AR 5.0)
|
30
|
+
cached_statement = fetch_cached_statement(sql) if prepare && supports_statement_cache?
|
35
31
|
@connection.execute_prepared_query(sql, binds, cached_statement)
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
36
|
def exec_update(sql, name = nil, binds = NO_BINDS)
|
41
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
42
|
-
|
43
37
|
if without_prepared_statement?(binds)
|
44
38
|
log(sql, name) { @connection.execute_update(sql) }
|
45
39
|
else
|