activerecord-jdbc-adapter 51.7-java → 52.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -2
  3. data/.travis.yml +26 -51
  4. data/README.md +9 -11
  5. data/Rakefile +19 -74
  6. data/activerecord-jdbc-adapter.gemspec +2 -2
  7. data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -0
  8. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
  9. data/lib/arjdbc/abstract/core.rb +2 -12
  10. data/lib/arjdbc/abstract/database_statements.rb +24 -10
  11. data/lib/arjdbc/abstract/statement_cache.rb +4 -4
  12. data/lib/arjdbc/db2/adapter.rb +52 -2
  13. data/lib/arjdbc/jdbc.rb +4 -0
  14. data/lib/arjdbc/jdbc/column.rb +11 -5
  15. data/lib/arjdbc/jdbc/connection_methods.rb +9 -2
  16. data/lib/arjdbc/jdbc/jdbc.rake +4 -0
  17. data/lib/arjdbc/mssql.rb +7 -0
  18. data/lib/arjdbc/mssql/adapter.rb +804 -0
  19. data/lib/arjdbc/mssql/column.rb +200 -0
  20. data/lib/arjdbc/mssql/connection_methods.rb +79 -0
  21. data/lib/arjdbc/mssql/explain_support.rb +99 -0
  22. data/lib/arjdbc/mssql/limit_helpers.rb +231 -0
  23. data/lib/arjdbc/mssql/lock_methods.rb +77 -0
  24. data/lib/arjdbc/mssql/types.rb +343 -0
  25. data/lib/arjdbc/mssql/utils.rb +82 -0
  26. data/lib/arjdbc/mysql/adapter.rb +22 -14
  27. data/lib/arjdbc/mysql/connection_methods.rb +9 -18
  28. data/lib/arjdbc/postgresql/adapter.rb +102 -75
  29. data/lib/arjdbc/postgresql/column.rb +3 -6
  30. data/lib/arjdbc/postgresql/connection_methods.rb +3 -12
  31. data/lib/arjdbc/postgresql/oid_types.rb +12 -86
  32. data/lib/arjdbc/sqlite3/adapter.rb +88 -92
  33. data/lib/arjdbc/sqlite3/connection_methods.rb +0 -1
  34. data/lib/arjdbc/tasks/database_tasks.rb +36 -16
  35. data/lib/arjdbc/tasks/databases.rake +75 -32
  36. data/lib/arjdbc/tasks/databases3.rake +215 -0
  37. data/lib/arjdbc/tasks/databases4.rake +39 -0
  38. data/lib/arjdbc/version.rb +1 -1
  39. data/rakelib/01-tomcat.rake +2 -2
  40. data/rakelib/02-test.rake +3 -0
  41. data/rakelib/compile.rake +70 -0
  42. data/rakelib/db.rake +7 -21
  43. data/rakelib/rails.rake +4 -5
  44. data/src/java/arjdbc/ArJdbcModule.java +15 -5
  45. data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +2 -2
  46. data/src/java/arjdbc/jdbc/ConnectionFactory.java +87 -0
  47. data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +1 -0
  48. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +29 -113
  49. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +14 -259
  50. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +2 -2
  51. data/src/java/arjdbc/postgresql/PgResultSetMetaDataWrapper.java +23 -0
  52. data/src/java/arjdbc/postgresql/PostgreSQLResult.java +13 -21
  53. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +50 -44
  54. data/src/java/arjdbc/util/DateTimeUtils.java +5 -141
  55. data/src/java/arjdbc/util/QuotingUtils.java +7 -6
  56. metadata +26 -11
  57. data/src/java/arjdbc/jdbc/RubyConnectionFactory.java +0 -61
  58. data/src/java/arjdbc/postgresql/PgDateTimeUtils.java +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a472f8ed7911f754bafc83ddf5d34fa061fda0d8b78a0a0d263e54ac4ae59ffa
4
- data.tar.gz: 1fd596cb2615ab284b647d6546e40eab484c9718890d0ee90e5a9220610762cc
3
+ metadata.gz: d4e30effdf5519398605801e776e032f385bba8da0008c15bdda99426ac0b2ee
4
+ data.tar.gz: 5c3075c02b57070186442fd4d8e88252ffab2db0f06ebed390dcdeb7556a27ba
5
5
  SHA512:
6
- metadata.gz: 7686dceb4704955a36053011ae7da81abc6384bd8ad213a171f99c2becb1d814138192f6f05923e2bfd1434e395b59e38418ffcd57ab7324d352c6a9a96b4bf2
7
- data.tar.gz: 0030c4eb8f4e61615f7d30b4a1693fa26729144e32484bfc02edccf418fe339f79736c0c4039e89a6e81159d9e45dbbf10cf18deab6bd2f5c3ee75ffa24db137
6
+ metadata.gz: 01c8df592aec36d47474c1968ff73e39f68414a3a3fbde27fcaa5c24fe078ee8cddb2b3f750d580660d567fb3323511e7ad9781913bb6fe658797a9445b42bce
7
+ data.tar.gz: 1940e41e96e0ac3af73bb0bbdd1dcc75c9c07554e2d3c05a8cc3bf3562cbd9fa9593919a8159c151577463ad676be42b92b2b61089efdebc9ad94fff34596ec7
data/.gitignore CHANGED
@@ -2,7 +2,6 @@
2
2
  *.tgz
3
3
  *~
4
4
  *.log
5
- /log/
6
5
  patches*
7
6
  *#
8
7
  TAGS
@@ -31,4 +30,4 @@ Gemfile.lock
31
30
  .idea
32
31
  .settings
33
32
  activerecord-jdbc.iml
34
- lib/arjdbc/jdbc/adapter_java.jar
33
+ lib/arjdbc/jdbc/adapter_java.jar
@@ -1,27 +1,9 @@
1
+ language: ruby
1
2
  sudo: false
2
- dist: xenial
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 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" && \
43
- mysql -e "CREATE DATABASE activerecord_unittest2 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" \
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
- - DB=jndi PREPARED_STATEMENTS=false
62
- - DB=jndi PREPARED_STATEMENTS=true
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.2
68
+ mariadb: '10.0'
94
69
  env: DB=mariadb PREPARED_STATEMENTS=false
95
70
  - addons:
96
- mariadb: 10.3
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.1.7" # PS off by default
100
- - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.7" PREPARED_STATEMENTS=true
101
- - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.7" DRIVER=MariaDB
102
- - env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.1.7" # PS on by default
103
- - env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.1.7" PREPARED_STATEMENTS=false
104
- - env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="v5.1.7"
74
+ - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.0" # PS off by default
75
+ - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.0" PREPARED_STATEMENTS=true
76
+ - env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.0" DRIVER=MariaDB
77
+ - env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.2.0" # PS on by default
78
+ - env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.2.0" PREPARED_STATEMENTS=false
79
+ - env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="v5.2.0"
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** and **MSSQL*** (SQLServer).
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
- Unless we get more contributions we will not be supporting more adapters.
11
- Note that the amount of work needed to get another adapter is not huge but
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-jdbcsqlserver-adapter
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
- include_jar = ENV['INCLUDE_JAR_IN_GEM'] || 'true'
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,16 +236,19 @@ if defined? JRUBY_VERSION
262
236
  end
263
237
 
264
238
  classpath = []
265
- [ 'java.class.path', 'sun.boot.class.path' ].map { |key| ENV_JAVA[key] }.each do |v|
266
- classpath += v.split(File::PATH_SEPARATOR).find_all { |jar| jar =~ /jruby/i } if v
239
+ ENV_PATHS = [ 'java.class.path', 'sun.boot.class.path' ]
240
+ ENV_PATHS.map { |key| ENV_JAVA[key] }.compact.each do |v|
241
+ classpath += v.split(File::PATH_SEPARATOR).find_all { |jar| jar =~ /jruby/i }
267
242
  end
268
- # Using Java 9+. Let's try and infer jruby.jar location from rbconfig
269
- if classpath.empty?; require 'rbconfig'
270
- libdir = RbConfig::CONFIG['libdir']
271
- if libdir.start_with? 'classpath:'
243
+
244
+ # Using Java 9+. Let's try and infer jruby jar location from rbconfig
245
+ if classpath.empty?
246
+ require 'rbconfig'
247
+ libdir = RbConfig::CONFIG["libdir"]
248
+ if libdir.start_with? "classpath:"
272
249
  error "Cannot build activerecord-jdbc with jruby-complete"
273
250
  end
274
- classpath << File.join(libdir, 'jruby.jar')
251
+ classpath << File.join(libdir, "jruby.jar")
275
252
  end
276
253
 
277
254
  classpath += driver_jars
@@ -279,26 +256,11 @@ if defined? JRUBY_VERSION
279
256
 
280
257
  source_files = FileList[ 'src/java/**/*.java' ]
281
258
 
282
- version = lambda do
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
259
+ require 'tmpdir'
299
260
 
300
- require 'tmpdir'; Dir.mktmpdir do |classes_dir|
301
- # Cross-platform way of finding an executable in the $PATH. Thanks to @mislav
261
+ Dir.mktmpdir do |classes_dir|
262
+ # Cross-platform way of finding an executable in the $PATH.
263
+ # Thanks to @mislav
302
264
  which = lambda do |cmd|
303
265
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
304
266
  ENV['PATH'].split(File::PATH_SEPARATOR).map do |path|
@@ -322,24 +284,7 @@ if defined? JRUBY_VERSION
322
284
  # avoid environment variable expansion using backslash
323
285
  # class_files.gsub!('$', '\$') unless windows?
324
286
  # 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}/ ." ]
287
+ args = [ '-C', "#{classes_dir}/ ." ] # args = class_files
343
288
 
344
289
  jar_path = jar_file
345
290
  if ext_lib_dir = ENV['RUBYLIBDIR']
@@ -349,7 +294,7 @@ if defined? JRUBY_VERSION
349
294
  unless jar = which.call('jar')
350
295
  warn "could not find jar tool, please make sure it's on the PATH"
351
296
  end
352
- sh("#{jar} #{opts} #{jar_path} #{args.join(' ')}") do |ok|
297
+ sh("#{jar} cf #{jar_path} #{args.join(' ')}") do |ok|
353
298
  raise 'could not build .jar extension - packaging failure' unless ok
354
299
  end
355
300
  cp jar_path, jar_file if ext_lib_dir # NOTE: hopefully RG won't mind?!
@@ -357,6 +302,6 @@ if defined? JRUBY_VERSION
357
302
  end
358
303
  else
359
304
  task :jar do
360
- warn "please run `rake jar' under JRuby to re-compile the native (Java) extension"
305
+ puts "please run `rake jar' under JRuby to re-compile the native (Java) extension"
361
306
  end
362
307
  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['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
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.1.0'
47
+ gem.add_dependency 'activerecord', '~> 5.2.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'
@@ -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.
@@ -56,21 +56,11 @@ module ArJdbc
56
56
  case e
57
57
  when SystemExit, SignalException, NoMemoryError then e
58
58
  when ActiveModel::RangeError, TypeError, RuntimeError then e
59
- else super
59
+ else ActiveRecord::StatementInvalid.new(message)
60
60
  end
61
61
  end
62
62
 
63
- def extract_raw_bind_values(binds)
64
- binds.map(&:value_for_database)
65
- end
66
63
 
67
- # this version of log() automatically fills type_casted_binds from binds if necessary
68
- def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
69
- if binds.any? && (type_casted_binds.nil? || type_casted_binds.empty?)
70
- type_casted_binds = ->{ extract_raw_bind_values(binds) }
71
- end
72
- super
73
- end
74
64
  end
75
65
  end
76
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.execute_insert_pk(sql, pk) }
14
+ log(sql, name) { @connection.execute_insert(sql) }
17
15
  else
18
16
  log(sql, name, binds) do
19
- @connection.execute_insert_pk(sql, binds, pk)
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
- # this is different from normal AR that always caches
34
- cached_statement = fetch_cached_statement(sql) if prepare && @jdbc_statement_cache_enabled
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
@@ -48,10 +42,30 @@ module ArJdbc
48
42
  end
49
43
  alias :exec_delete :exec_update
50
44
 
45
+ # overridden to support legacy binds
46
+ def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
47
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
48
+ super
49
+ end
50
+ alias create insert
51
+
52
+ # overridden to support legacy binds
53
+ def update(arel, name = nil, binds = [])
54
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
55
+ super
56
+ end
57
+
58
+ # overridden to support legacy binds
59
+ def delete(arel, name = nil, binds = [])
60
+ binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
61
+ super
62
+ end
63
+
51
64
  def execute(sql, name = nil)
52
65
  log(sql, name) { @connection.execute(sql) }
53
66
  end
54
67
 
68
+ # overridden to support legacy binds
55
69
  def select_all(arel, name = nil, binds = NO_BINDS, preparable: nil)
56
70
  binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
57
71
  super