activerecord-jdbc-alt-adapter 50.7.0-java → 51.3.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.
- checksums.yaml +4 -4
- data/.gitignore +0 -3
- data/.travis.yml +24 -28
- data/Gemfile +5 -2
- data/README.md +26 -20
- data/Rakefile +4 -30
- data/activerecord-jdbc-adapter.gemspec +2 -2
- data/activerecord-jdbc-alt-adapter.gemspec +4 -3
- data/lib/arel/visitors/sqlserver.rb +17 -3
- data/lib/arjdbc/abstract/core.rb +4 -2
- data/lib/arjdbc/abstract/database_statements.rb +2 -8
- data/lib/arjdbc/abstract/transaction_support.rb +2 -9
- data/lib/arjdbc/db2/adapter.rb +2 -52
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/column.rb +11 -5
- data/lib/arjdbc/jdbc/error.rb +1 -1
- data/lib/arjdbc/jdbc.rb +4 -0
- data/lib/arjdbc/mssql/adapter.rb +33 -39
- data/lib/arjdbc/mssql/connection_methods.rb +0 -5
- data/lib/arjdbc/mssql/database_statements.rb +1 -1
- data/lib/arjdbc/mssql/explain_support.rb +1 -1
- data/lib/arjdbc/mssql/{extensions.rb → extensions/attribute_methods.rb} +0 -0
- data/lib/arjdbc/mssql/extensions/calculations.rb +29 -0
- data/lib/arjdbc/mssql/schema_creation.rb +12 -0
- data/lib/arjdbc/mssql/schema_definitions.rb +17 -0
- data/lib/arjdbc/mssql/schema_dumper.rb +37 -0
- data/lib/arjdbc/mssql/schema_statements.rb +73 -44
- data/lib/arjdbc/mssql/types/date_and_time_types.rb +9 -9
- data/lib/arjdbc/mssql/utils.rb +1 -0
- data/lib/arjdbc/mssql.rb +1 -1
- data/lib/arjdbc/mysql/adapter.rb +12 -1
- data/lib/arjdbc/mysql/connection_methods.rb +7 -13
- data/lib/arjdbc/postgresql/adapter.rb +29 -12
- data/lib/arjdbc/postgresql/column.rb +3 -6
- data/lib/arjdbc/postgresql/connection_methods.rb +1 -3
- data/lib/arjdbc/postgresql/oid_types.rb +7 -12
- data/lib/arjdbc/sqlite3/adapter.rb +169 -139
- data/lib/arjdbc/sqlite3/connection_methods.rb +1 -2
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/01-tomcat.rake +2 -2
- data/rakelib/02-test.rake +2 -0
- data/rakelib/rails.rake +1 -1
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +17 -68
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +38 -282
- data/src/java/arjdbc/postgresql/ByteaUtils.java +1 -0
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +3 -3
- data/src/java/arjdbc/util/DateTimeUtils.java +5 -22
- metadata +20 -12
- data/lib/activerecord-jdbc-alt-adapter.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a685f3d4b7d4a927785b4c4e6d0617967552c297e87a65cf1f66ea7e0fdd5c83
|
4
|
+
data.tar.gz: ca34ee0b1f3bb347e54815af6272f6eb4e183daa9f35dc739e8d60bc3630cfd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a83701ef6268570ede2d819b1f2296eede75f30d9a75c7ae21ce87cd6eea95584bd096019d7e80149476f7107e7310dbd0c701f8eadc0c28fbd87cde2155568
|
7
|
+
data.tar.gz: 4764519a0791450964dd35136ec81584934bfc08ab81fd1d1cd8bbe912aa602d55ed3525cec59c45dd863c64e94a6da506c9cd10932b755a76e8d31d05ee3188
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,27 +1,18 @@
|
|
1
|
+
language: ruby
|
1
2
|
sudo: false
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
branches:
|
4
|
+
only:
|
5
|
+
- master
|
6
|
+
- /.*-stable$/
|
7
|
+
- /^test-.*/
|
8
|
+
- /maintenance|support/
|
9
|
+
- /.*dev$/
|
10
|
+
bundler_args: --without development
|
11
|
+
script: bundle exec rake ${TEST_PREFIX}test_$DB
|
9
12
|
before_install:
|
10
13
|
- unset _JAVA_OPTIONS
|
11
14
|
- rvm @default,@global do gem uninstall bundler -a -x -I || true
|
12
15
|
- 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
16
|
before_script:
|
26
17
|
- echo "JAVA_OPTS=$JAVA_OPTS"
|
27
18
|
- export JRUBY_OPTS="-J-Xms64M -J-Xmx1024M"
|
@@ -47,7 +38,12 @@ before_script:
|
|
47
38
|
psql -c "create database activerecord_unittest;" -U postgres && \
|
48
39
|
psql -c "create database activerecord_unittest2;" -U postgres \
|
49
40
|
|| true
|
50
|
-
|
41
|
+
rvm:
|
42
|
+
- jruby-9.1.16.0
|
43
|
+
jdk:
|
44
|
+
- openjdk8
|
45
|
+
addons:
|
46
|
+
postgresql: "9.4"
|
51
47
|
env:
|
52
48
|
- DB=mysql2 PREPARED_STATEMENTS=false
|
53
49
|
- DB=mysql2 PREPARED_STATEMENTS=true
|
@@ -90,15 +86,15 @@ matrix:
|
|
90
86
|
env: DB=sqlite3
|
91
87
|
# testing against MariaDB
|
92
88
|
- addons:
|
93
|
-
mariadb: 10.
|
89
|
+
mariadb: '10.0'
|
94
90
|
env: DB=mariadb PREPARED_STATEMENTS=false
|
95
91
|
- addons:
|
96
|
-
mariadb: 10.
|
92
|
+
mariadb: '10.1'
|
97
93
|
env: DB=mariadb PREPARED_STATEMENTS=true
|
98
94
|
# 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.
|
95
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.7" # PS off by default
|
96
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.7" PREPARED_STATEMENTS=true
|
97
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.1.7" DRIVER=MariaDB
|
98
|
+
- env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.1.7" # PS on by default
|
99
|
+
- env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="v5.1.7" PREPARED_STATEMENTS=false
|
100
|
+
- env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="v5.1.7"
|
data/Gemfile
CHANGED
@@ -48,8 +48,8 @@ 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 '
|
52
|
-
gem '
|
51
|
+
gem 'jdbc-mssql', '~> 0.6.0', require: nil
|
52
|
+
# gem 'pry-debugger-jruby', platform: :jruby
|
53
53
|
end
|
54
54
|
|
55
55
|
group :rails do
|
@@ -62,6 +62,9 @@ group :rails do
|
|
62
62
|
gem 'benchmark-ips', require: nil
|
63
63
|
end
|
64
64
|
|
65
|
+
# AR expects this for testing xml in postgres (maybe others?)
|
66
|
+
gem 'builder', require: nil
|
67
|
+
|
65
68
|
gem 'erubis', require: nil # "~> 2.7.0"
|
66
69
|
# NOTE: due rails/activerecord/test/cases/connection_management_test.rb
|
67
70
|
gem 'rack', require: nil
|
data/README.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
# ActiveRecord JDBC Alternative Adapter
|
2
2
|
|
3
3
|
This adapter is a fork of the ActiveRecord JDBC Adapter with basic support for
|
4
|
-
**SQL Server/Azure SQL
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
**SQL Server/Azure SQL**. This adapter may work with other databases
|
5
|
+
supported by the original adapter such as PostgreSQL but it is advised to
|
6
|
+
use the [original adapter](https://github.com/jruby/active)
|
7
|
+
|
8
|
+
This adapter only works with JRuby and it is advised to install the latest
|
9
|
+
stable versins of Rails
|
10
|
+
|
11
|
+
- For Rails `5.0.7.2` install the `50.3.1` version of this adapter
|
12
|
+
- For Rails `5.1.7` install the `51.3.0` version of this adapter
|
13
|
+
|
14
|
+
Support for Rails 5.2 is planned in the near future.
|
8
15
|
|
9
16
|
|
10
17
|
### How to use it:
|
@@ -29,16 +36,17 @@ and see how is set up.
|
|
29
36
|
support that SQL dialect.
|
30
37
|
- This adapter uses the `datetime2` sql data type as the Rails logical `datetime` data type.
|
31
38
|
- This adapter needs the mssql jdbc driver version 7.0.0 onwards to work properly,
|
32
|
-
therefore you can use the gem `jdbc-mssql` version `0.
|
39
|
+
therefore you can use the gem `jdbc-mssql` version `0.6.0` onwards or the actual
|
33
40
|
driver jar file version `7.0.0`.
|
34
41
|
|
35
42
|
|
36
43
|
### Recommendation
|
37
44
|
|
38
|
-
If you have the old sql server `datetime` data type for created_at and
|
39
|
-
updated_at
|
40
|
-
(`datetime_basic`) will still work
|
41
|
-
aware list.
|
45
|
+
If you have the old sql server `datetime` data type for `created_at` and
|
46
|
+
`updated_at`, you don't need to upgrade straightaway to `datetime2`, the old data type
|
47
|
+
(`datetime_basic`) will still work for simple updates, just make you add to the time zone
|
48
|
+
aware list. If you have complex `datetime` queries it is advised to upgrade to
|
49
|
+
`datetime2`
|
42
50
|
|
43
51
|
```ruby
|
44
52
|
# time zone aware configuration.
|
@@ -106,16 +114,15 @@ this adapter should just work.
|
|
106
114
|
ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails'
|
107
115
|
*ActiveRecord* component that can be used with [JRuby][0].
|
108
116
|
ActiveRecord-JDBC-Adapter provides full or nearly full support for:
|
109
|
-
**MySQL**, **PostgreSQL**, **SQLite3
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
117
|
+
**MySQL**, **PostgreSQL**, **SQLite3**. In the near future there are plans to
|
118
|
+
add support **MSSQL**. Unless we get more contributions we will not be going
|
119
|
+
beyond these four adapters. Note that the amount of work needed to get
|
120
|
+
another adapter is not huge but the amount of testing required to make sure
|
121
|
+
that adapter continues to work is not something we can do with the resources
|
122
|
+
we currently have.
|
115
123
|
|
116
|
-
|
117
|
-
|
118
|
-
- **MSSQL** adapter's gem parts reside in a [separate repository][8]
|
124
|
+
For Oracle database users you are encouraged to use
|
125
|
+
https://github.com/rsim/oracle-enhanced.
|
119
126
|
|
120
127
|
Version **50.x** supports Rails version 5.0.x and it lives on branch 50-stable.
|
121
128
|
Version **51.x** supports Rails version 5.1.x and is currently on master until
|
@@ -134,7 +141,6 @@ adapters are available:
|
|
134
141
|
- MySQL (`activerecord-jdbcmysql-adapter`)
|
135
142
|
- PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
|
136
143
|
- SQLite3 (`activerecord-jdbcsqlite3-adapter`)
|
137
|
-
- MSSQL (`activerecord-jdbcsqlserver-adapter`)
|
138
144
|
|
139
145
|
2. If you're generating a new Rails application, use the following command:
|
140
146
|
|
@@ -269,4 +275,4 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
|
|
269
275
|
[5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
|
270
276
|
[6]: https://webchat.freenode.net/?channels=#jruby
|
271
277
|
[7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
|
272
|
-
[8]: https://github.com/jruby/activerecord-
|
278
|
+
[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
|
|
@@ -283,7 +257,7 @@ if defined? JRUBY_VERSION
|
|
283
257
|
begin
|
284
258
|
require 'arjdbc/version'
|
285
259
|
rescue LoadError
|
286
|
-
path = File.expand_path('lib', File.dirname(__FILE__))
|
260
|
+
path = File.expand_path('../lib', File.dirname(__FILE__))
|
287
261
|
unless $LOAD_PATH.include?(path)
|
288
262
|
$LOAD_PATH << path; retry
|
289
263
|
end
|
@@ -323,7 +297,7 @@ if defined? JRUBY_VERSION
|
|
323
297
|
# class_files.gsub!('$', '\$') unless windows?
|
324
298
|
# args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
|
325
299
|
|
326
|
-
if ENV['
|
300
|
+
if ENV['RELEASE'] == 'true'; require 'tempfile'
|
327
301
|
manifest = "Built-Time: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')}\n"
|
328
302
|
manifest += "Built-JRuby: #{JRUBY_VERSION}\n"
|
329
303
|
manifest += "Specification-Title: ActiveRecord-JDBC\n"
|
@@ -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'
|
@@ -11,7 +11,8 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.license = 'BSD-2-Clause'
|
12
12
|
gem.summary = 'ActiveRecord JDBC adapter, for use within JRuby on Rails and SQL Server'
|
13
13
|
gem.description = "" <<
|
14
|
-
"Fork of the ActiveRecord JDBC adapter with support for SQL Server
|
14
|
+
"Fork of the ActiveRecord JDBC adapter with support for SQL Server/Azure SQL, " <<
|
15
|
+
"for more information and help look at the README file in the github repository. " <<
|
15
16
|
"AR-JDBC is a database adapter for Rails' ActiveRecord component designed " <<
|
16
17
|
"to be used with JRuby built upon Java's JDBC API for database access. " <<
|
17
18
|
"Provides (ActiveRecord) built-in adapters: MySQL, PostgreSQL and SQLite3 " <<
|
@@ -28,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
28
29
|
reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
|
29
30
|
gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
|
30
31
|
|
31
|
-
if ENV['
|
32
|
+
if ENV['RELEASE'] != 'true' # @see Rakefile
|
32
33
|
gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
|
33
34
|
|
34
35
|
#gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
|
@@ -45,7 +46,7 @@ Gem::Specification.new do |gem|
|
|
45
46
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
46
47
|
gem.test_files = gem.files.grep(%r{^test/})
|
47
48
|
|
48
|
-
gem.add_dependency 'activerecord', '~> 5.
|
49
|
+
gem.add_dependency 'activerecord', '~> 5.1.0', '>= 5.1.7'
|
49
50
|
|
50
51
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
51
52
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
@@ -99,17 +99,29 @@ module Arel
|
|
99
99
|
collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector
|
100
100
|
end
|
101
101
|
if o.right.any?
|
102
|
-
collector <<
|
102
|
+
collector << SPACE if o.left
|
103
103
|
collector = inject_join o.right, collector, ' '
|
104
104
|
end
|
105
105
|
collector
|
106
106
|
end
|
107
107
|
|
108
|
+
def visit_Arel_Nodes_InnerJoin o, collector
|
109
|
+
collector << "INNER JOIN "
|
110
|
+
collector = visit o.left, collector
|
111
|
+
collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, space: true
|
112
|
+
if o.right
|
113
|
+
collector << SPACE
|
114
|
+
visit(o.right, collector)
|
115
|
+
else
|
116
|
+
collector
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
108
120
|
def visit_Arel_Nodes_OuterJoin o, collector
|
109
121
|
collector << "LEFT OUTER JOIN "
|
110
122
|
collector = visit o.left, collector
|
111
123
|
collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, space: true
|
112
|
-
collector <<
|
124
|
+
collector << SPACE
|
113
125
|
visit o.right, collector
|
114
126
|
end
|
115
127
|
|
@@ -199,7 +211,9 @@ module Arel
|
|
199
211
|
|
200
212
|
def primary_Key_From_Table t
|
201
213
|
return unless t
|
202
|
-
column_name = schema_cache.primary_keys(t.name) || column_cache(t.name).first.try(:second).try(:name)
|
214
|
+
# column_name = schema_cache.primary_keys(t.name) || column_cache(t.name).first.try(:second).try(:name)
|
215
|
+
column_name = @connection.schema_cache.primary_keys(t.name) ||
|
216
|
+
@connection.schema_cache.columns_hash(t.name).first.try(:second).try(:name)
|
203
217
|
column_name ? t[column_name] : nil
|
204
218
|
end
|
205
219
|
|
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,7 +56,7 @@ 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
|
|
@@ -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,8 +22,6 @@ 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
|
@@ -38,8 +34,6 @@ module ArJdbc
|
|
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
|
@@ -13,15 +13,8 @@ module ArJdbc
|
|
13
13
|
@connection.supports_savepoints?
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
# isolation level support by the database.
|
19
|
-
# @param level optional to check if we support a specific isolation level
|
20
|
-
# @since 1.3.0
|
21
|
-
# @extension added optional level parameter
|
22
|
-
def supports_transaction_isolation?(level = nil)
|
23
|
-
return false unless level
|
24
|
-
@connection.supports_transaction_isolation?(level)
|
16
|
+
def supports_transaction_isolation?
|
17
|
+
@connection.supports_transaction_isolation?
|
25
18
|
end
|
26
19
|
|
27
20
|
########################## Transaction Interface ##########################
|
data/lib/arjdbc/db2/adapter.rb
CHANGED
@@ -342,60 +342,10 @@ module ArJdbc
|
|
342
342
|
|
343
343
|
# Properly quotes the various data types.
|
344
344
|
# @param value contains the data
|
345
|
-
# @param column (optional) contains info on the field
|
346
345
|
# @override
|
347
|
-
def quote(value
|
348
|
-
return value.quoted_id if value.respond_to?(:quoted_id)
|
346
|
+
def quote(value)
|
349
347
|
return value if sql_literal?(value)
|
350
|
-
|
351
|
-
if column
|
352
|
-
if column.respond_to?(:primary) && column.primary && column.klass != String
|
353
|
-
return value.to_i.to_s
|
354
|
-
end
|
355
|
-
if value && (column.type.to_sym == :decimal || column.type.to_sym == :integer)
|
356
|
-
return value.to_s
|
357
|
-
end
|
358
|
-
end
|
359
|
-
|
360
|
-
column_type = column && column.type.to_sym
|
361
|
-
|
362
|
-
case value
|
363
|
-
when nil then 'NULL'
|
364
|
-
when Numeric # IBM_DB doesn't accept quotes on numeric types
|
365
|
-
# if the column type is text or string, return the quote value
|
366
|
-
if column_type == :text || column_type == :string
|
367
|
-
"'#{value}'"
|
368
|
-
else
|
369
|
-
value.to_s
|
370
|
-
end
|
371
|
-
when String, ActiveSupport::Multibyte::Chars
|
372
|
-
if column_type == :binary && column.sql_type !~ /for bit data/i
|
373
|
-
if update_lob_value?(value, column)
|
374
|
-
value.nil? ? 'NULL' : BLOB_VALUE_MARKER # '@@@IBMBINARY@@@'"
|
375
|
-
else
|
376
|
-
"BLOB('#{quote_string(value)}')"
|
377
|
-
end
|
378
|
-
elsif column && column.sql_type =~ /clob/ # :text
|
379
|
-
if update_lob_value?(value, column)
|
380
|
-
value.nil? ? 'NULL' : CLOB_VALUE_MARKER # "'@@@IBMTEXT@@@'"
|
381
|
-
else
|
382
|
-
"'#{quote_string(value)}'"
|
383
|
-
end
|
384
|
-
elsif column_type == :xml
|
385
|
-
value.nil? ? 'NULL' : "'#{quote_string(value)}'" # "'<ibm>@@@IBMXML@@@</ibm>'"
|
386
|
-
else
|
387
|
-
"'#{quote_string(value)}'"
|
388
|
-
end
|
389
|
-
when Symbol then "'#{quote_string(value.to_s)}'"
|
390
|
-
when Time
|
391
|
-
# AS400 doesn't support date in time column
|
392
|
-
if column_type == :time
|
393
|
-
quote_time(value)
|
394
|
-
else
|
395
|
-
super
|
396
|
-
end
|
397
|
-
else super
|
398
|
-
end
|
348
|
+
super
|
399
349
|
end
|
400
350
|
|
401
351
|
# @override
|
Binary file
|
data/lib/arjdbc/jdbc/column.rb
CHANGED
@@ -26,17 +26,23 @@ module ActiveRecord
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
if ArJdbc::AR50
|
30
|
+
default = args[0].cast(default)
|
30
31
|
|
31
|
-
|
32
|
-
|
32
|
+
sql_type = args.delete_at(1)
|
33
|
+
type = args.delete_at(0)
|
33
34
|
|
34
|
-
|
35
|
+
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
|
36
|
+
elsif ArJdbc::AR42
|
37
|
+
default = args[0].type_cast_from_database(default)
|
38
|
+
else
|
39
|
+
default = default_value(default)
|
40
|
+
end
|
35
41
|
|
36
42
|
# super <= 4.1: (name, default, sql_type = nil, null = true)
|
37
43
|
# super >= 4.2: (name, default, cast_type, sql_type = nil, null = true)
|
38
44
|
# super >= 5.0: (name, default, sql_type_metadata = nil, null = true)
|
39
|
-
|
45
|
+
|
40
46
|
super(name, default, *args)
|
41
47
|
init_column(name, default, *args)
|
42
48
|
end
|
data/lib/arjdbc/jdbc/error.rb
CHANGED
@@ -3,7 +3,7 @@ module ActiveRecord
|
|
3
3
|
class JDBCError < WrappedDatabaseException
|
4
4
|
|
5
5
|
def initialize(message = nil, cause = $!)
|
6
|
-
super( ( message.nil? && cause ) ? cause.message : message
|
6
|
+
super( ( message.nil? && cause ) ? cause.message : message )
|
7
7
|
if cause.is_a? Java::JavaSql::SQLException
|
8
8
|
@jdbc_exception, @cause = cause, nil
|
9
9
|
else
|
data/lib/arjdbc/jdbc.rb
CHANGED