activerecord-jdbc-adapter 1.3.25 → 5.0.pre1
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/.travis.yml +57 -72
- data/Appraisals +7 -2
- data/Gemfile +3 -7
- data/History.md +0 -50
- data/RUNNING_TESTS.md +4 -0
- data/activerecord-jdbc-adapter.gemspec +2 -1
- data/lib/arjdbc/common_jdbc_methods.rb +89 -0
- data/lib/arjdbc/db2/adapter.rb +58 -69
- data/lib/arjdbc/db2/as400.rb +2 -13
- data/lib/arjdbc/db2/column.rb +1 -1
- data/lib/arjdbc/derby/adapter.rb +2 -6
- data/lib/arjdbc/firebird/adapter.rb +7 -16
- data/lib/arjdbc/h2/adapter.rb +4 -13
- data/lib/arjdbc/hsqldb/adapter.rb +5 -5
- data/lib/arjdbc/jdbc/adapter.rb +15 -76
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +12 -31
- data/lib/arjdbc/jdbc/base_ext.rb +6 -25
- data/lib/arjdbc/jdbc/column.rb +15 -1
- data/lib/arjdbc/jdbc/connection_methods.rb +7 -1
- data/lib/arjdbc/jdbc/type_cast.rb +16 -4
- data/lib/arjdbc/jdbc/type_converter.rb +0 -1
- data/lib/arjdbc/mssql/adapter.rb +9 -21
- data/lib/arjdbc/mysql/adapter.rb +14 -19
- data/lib/arjdbc/mysql/connection_methods.rb +3 -5
- data/lib/arjdbc/oracle/adapter.rb +4 -38
- data/lib/arjdbc/oracle/connection_methods.rb +0 -4
- data/lib/arjdbc/postgresql/adapter.rb +18 -22
- data/lib/arjdbc/postgresql/connection_methods.rb +2 -5
- data/lib/arjdbc/postgresql/oid/bytea.rb +0 -1
- data/lib/arjdbc/postgresql/oid_types.rb +6 -6
- data/lib/arjdbc/sqlite3/adapter.rb +493 -404
- data/lib/arjdbc/tasks/database_tasks.rb +1 -1
- data/lib/arjdbc/tasks/databases3.rake +1 -1
- data/lib/arjdbc/tasks/databases4.rake +3 -8
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/db.rake +5 -8
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +102 -37
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +0 -7
- metadata +10 -17
- data/lib/arjdbc/jdbc/arel_support.rb +0 -133
- data/lib/arjdbc/mssql/attributes_for_update.rb +0 -22
- data/lib/arjdbc/sqlite3/explain_support.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16bdeec72b7b2db4b9593138ae56a56cb52fd7d7
|
4
|
+
data.tar.gz: d3a6f0d4a0593326b598f9fda7ac77f0bb9266a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e9df27017621984d70cc5a824a2d82775b8a6cd21b7307769557f7e154c1e1b95bead7c411aed5e16d9af85ab26a8ddba8cf58edce863ed5c0f1491b587101e
|
7
|
+
data.tar.gz: 6b5449e2e4e0f126046a68811acb030a0032b3f7b1f91e5a2a7a7a96fb83cd1d01f1c686e1266311a60a629ad9634bcf70ce63ea30776709b1f2cb59b011e047
|
data/.travis.yml
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
addons:
|
2
|
-
apt:
|
3
|
-
packages:
|
4
|
-
- openjdk-6-jdk
|
5
|
-
|
6
1
|
language: ruby
|
7
2
|
sudo: false
|
8
3
|
bundler_args: --without development
|
@@ -51,110 +46,104 @@ branches:
|
|
51
46
|
- /^test-.*/
|
52
47
|
matrix:
|
53
48
|
allow_failures:
|
54
|
-
#
|
55
|
-
-
|
56
|
-
|
57
|
-
|
49
|
+
# yet another BC timestamp issue: <Wed, 31 Dec -0001 22:58:59 +0000> expected but was <Fri, 02 Jan 0000 22:58:59 +0000>
|
50
|
+
- rvm: jruby-9.0.5.0
|
51
|
+
gemfile: gemfiles/rails41.gemfile
|
52
|
+
env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
|
53
|
+
jdk: oraclejdk7
|
54
|
+
# ``/system call symlink regression (since JRuby 1.7.19)
|
55
|
+
# + (postgres) database_tasks got updated on 4.2 : https://github.com/rails/rails/commit/07f8a96aa14b642a86
|
56
|
+
- rvm: jruby-1.7.24
|
57
|
+
gemfile: gemfiles/rails42.gemfile
|
58
|
+
env: JRUBY_OPTS="--1.9 $JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=true
|
59
|
+
- rvm: jruby-1.7.24
|
60
|
+
gemfile: gemfiles/rails42.gemfile
|
61
|
+
env: JRUBY_OPTS="--1.9 $JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true
|
62
|
+
- rvm: jruby-1.7.24
|
63
|
+
gemfile: gemfiles/rails42.gemfile
|
64
|
+
env: JRUBY_OPTS="--1.9 $JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
|
65
|
+
- rvm: jruby-1.7.24
|
66
|
+
gemfile: gemfiles/rails42.gemfile
|
67
|
+
env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
|
58
68
|
include:
|
59
69
|
# testing against MariaDB
|
60
70
|
- addons:
|
61
|
-
mariadb: '
|
71
|
+
mariadb: '5.5'
|
62
72
|
rvm: jruby-1.7.24
|
63
73
|
gemfile: gemfiles/rails32.gemfile
|
64
74
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
|
65
|
-
jdk:
|
75
|
+
jdk: openjdk6
|
66
76
|
- addons:
|
67
|
-
mariadb: '10.
|
77
|
+
mariadb: '10.0'
|
68
78
|
rvm: jruby-1.7.24
|
69
|
-
gemfile: gemfiles/
|
70
|
-
env: DB=mariadb
|
71
|
-
jdk:
|
79
|
+
gemfile: gemfiles/rails40.gemfile
|
80
|
+
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mariadb
|
81
|
+
jdk: openjdk7
|
72
82
|
- addons:
|
73
|
-
mariadb: '10.
|
83
|
+
mariadb: '10.0'
|
74
84
|
rvm: jruby-1.7.24
|
75
85
|
gemfile: gemfiles/rails41.gemfile
|
76
|
-
env: DB=mariadb PREPARED_STATEMENTS=true
|
86
|
+
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mariadb PREPARED_STATEMENTS=true
|
77
87
|
jdk: oraclejdk8
|
78
88
|
# include some tests on JDK 6 :
|
79
|
-
- rvm: jruby-1.7.
|
89
|
+
- rvm: jruby-1.7.24
|
80
90
|
gemfile: gemfiles/rails42.gemfile
|
81
|
-
env: JRUBY_OPTS="
|
91
|
+
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
|
82
92
|
jdk: openjdk6
|
83
|
-
- rvm: jruby-1.7.
|
93
|
+
- rvm: jruby-1.7.24
|
84
94
|
gemfile: gemfiles/rails42.gemfile
|
85
|
-
env: JRUBY_OPTS="
|
95
|
+
env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
|
86
96
|
jdk: openjdk6
|
87
|
-
- rvm: jruby-1.7.
|
97
|
+
- rvm: jruby-1.7.24
|
88
98
|
gemfile: gemfiles/rails42.gemfile
|
89
99
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
|
90
100
|
jdk: openjdk6
|
91
|
-
- rvm: jruby-1.7.
|
101
|
+
- rvm: jruby-1.7.24
|
92
102
|
gemfile: gemfiles/rails42.gemfile
|
93
103
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=derby
|
94
104
|
jdk: openjdk6
|
95
|
-
- rvm: jruby-1.7.
|
105
|
+
- rvm: jruby-1.7.24
|
96
106
|
gemfile: gemfiles/rails42.gemfile
|
97
107
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=h2
|
98
108
|
jdk: openjdk6
|
99
|
-
- rvm: jruby-1.7.
|
109
|
+
- rvm: jruby-1.7.24
|
100
110
|
gemfile: gemfiles/rails42.gemfile
|
101
111
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=hsqldb
|
102
112
|
jdk: openjdk6
|
103
|
-
# include some (more) --2.0 testing :
|
104
|
-
- rvm: jruby-1.7.27
|
105
|
-
gemfile: gemfiles/rails41.gemfile
|
106
|
-
env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=mysql
|
107
|
-
jdk: openjdk8
|
108
|
-
- rvm: jruby-1.7.27
|
109
|
-
gemfile: gemfiles/rails41.gemfile
|
110
|
-
env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=postgresql
|
111
|
-
jdk: openjdk7
|
112
|
-
- rvm: jruby-1.7.27
|
113
|
-
gemfile: gemfiles/rails41.gemfile
|
114
|
-
env: JRUBY_OPTS="--2.0 $JRUBY_OPTS" DB=sqlite3
|
115
|
-
jdk: openjdk7
|
116
113
|
# include testing with JRuby 9K (4.2) :
|
117
|
-
- rvm: jruby-9.
|
114
|
+
- rvm: jruby-9.0.5.0
|
118
115
|
gemfile: gemfiles/rails42.gemfile
|
119
116
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql PREPARED_STATEMENTS=true
|
120
|
-
jdk:
|
121
|
-
- rvm: jruby-9.
|
122
|
-
gemfile: gemfiles/rails42.gemfile
|
123
|
-
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql DRIVER=MariaDB PREPARED_STATEMENTS=true
|
124
|
-
jdk: openjdk8
|
125
|
-
- rvm: jruby-9.1.12.0
|
117
|
+
jdk: oraclejdk7
|
118
|
+
- rvm: jruby-9.0.5.0
|
126
119
|
gemfile: gemfiles/rails42.gemfile
|
127
120
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql PREPARED_STATEMENTS=true
|
128
|
-
jdk:
|
129
|
-
- rvm: jruby-9.
|
121
|
+
jdk: oraclejdk7
|
122
|
+
- rvm: jruby-9.0.5.0
|
130
123
|
gemfile: gemfiles/rails42.gemfile
|
131
124
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
|
132
|
-
jdk:
|
133
|
-
- rvm: jruby-9.
|
125
|
+
jdk: oraclejdk7
|
126
|
+
- rvm: jruby-9.0.5.0
|
134
127
|
gemfile: gemfiles/rails42.gemfile
|
135
128
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
|
136
129
|
jdk: oraclejdk8
|
137
|
-
- rvm: jruby-9.
|
138
|
-
gemfile: gemfiles/rails42.gemfile
|
139
|
-
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql DRIVER=MariaDB
|
140
|
-
jdk: oraclejdk8
|
141
|
-
- rvm: jruby-9.1.13.0
|
130
|
+
- rvm: jruby-9.0.5.0
|
142
131
|
gemfile: gemfiles/rails42.gemfile
|
143
132
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
|
144
133
|
jdk: oraclejdk8
|
145
|
-
- rvm: jruby-9.
|
134
|
+
- rvm: jruby-9.0.5.0
|
146
135
|
gemfile: gemfiles/rails42.gemfile
|
147
136
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
|
148
137
|
jdk: oraclejdk8
|
149
|
-
- rvm: jruby-9.
|
138
|
+
- rvm: jruby-9.0.5.0
|
150
139
|
gemfile: gemfiles/rails42.gemfile
|
151
140
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=derby
|
152
141
|
jdk: oraclejdk8
|
153
|
-
- rvm: jruby-9.
|
142
|
+
- rvm: jruby-9.0.5.0
|
154
143
|
gemfile: gemfiles/rails42.gemfile
|
155
144
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=h2
|
156
145
|
jdk: oraclejdk8
|
157
|
-
- rvm: jruby-9.
|
146
|
+
- rvm: jruby-9.0.5.0
|
158
147
|
gemfile: gemfiles/rails42.gemfile
|
159
148
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=hsqldb
|
160
149
|
jdk: oraclejdk8
|
@@ -171,31 +160,27 @@ matrix:
|
|
171
160
|
gemfile: gemfiles/rails41.gemfile
|
172
161
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
|
173
162
|
jdk: oraclejdk8
|
174
|
-
- rvm: jruby-9.
|
163
|
+
- rvm: jruby-9.0.5.0
|
175
164
|
gemfile: gemfiles/rails41.gemfile
|
176
165
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql
|
177
|
-
jdk:
|
178
|
-
- rvm: jruby-9.
|
179
|
-
gemfile: gemfiles/rails41.gemfile
|
180
|
-
env: JRUBY_OPTS="$JRUBY_OPTS" DB=mysql DRIVER=MariaDB
|
181
|
-
jdk: openjdk8 # MariaDB 2.x assumes JDK 8
|
182
|
-
- rvm: jruby-9.1.13.0
|
166
|
+
jdk: oraclejdk7
|
167
|
+
- rvm: jruby-9.0.5.0
|
183
168
|
gemfile: gemfiles/rails41.gemfile
|
184
169
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=postgresql
|
185
|
-
jdk:
|
186
|
-
- rvm: jruby-9.
|
170
|
+
jdk: oraclejdk7
|
171
|
+
- rvm: jruby-9.0.5.0
|
187
172
|
gemfile: gemfiles/rails41.gemfile
|
188
173
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=sqlite3
|
189
174
|
jdk: oraclejdk8
|
190
|
-
- rvm: jruby-9.
|
175
|
+
- rvm: jruby-9.0.5.0
|
191
176
|
gemfile: gemfiles/rails41.gemfile
|
192
177
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=derby
|
193
|
-
jdk:
|
194
|
-
- rvm: jruby-9.
|
178
|
+
jdk: oraclejdk7
|
179
|
+
- rvm: jruby-9.0.5.0
|
195
180
|
gemfile: gemfiles/rails41.gemfile
|
196
181
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=h2
|
197
|
-
jdk:
|
198
|
-
- rvm: jruby-9.
|
182
|
+
jdk: oraclejdk7
|
183
|
+
- rvm: jruby-9.0.5.0
|
199
184
|
gemfile: gemfiles/rails41.gemfile
|
200
185
|
env: JRUBY_OPTS="$JRUBY_OPTS" DB=hsqldb
|
201
186
|
jdk: oraclejdk8
|
data/Appraisals
CHANGED
@@ -21,13 +21,18 @@ appraise "rails40" do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
appraise "rails41" do
|
24
|
-
gem "activerecord", "~> 4.1.
|
24
|
+
gem "activerecord", "~> 4.1.8", :require => false
|
25
25
|
end
|
26
26
|
|
27
27
|
appraise "rails42" do
|
28
|
-
gem "activerecord", "~> 4.2.
|
28
|
+
gem "activerecord", "~> 4.2.0", :require => false
|
29
29
|
end
|
30
30
|
|
31
|
+
appraise "rails50" do
|
32
|
+
gem "activerecord", "~> 5.0.0.beta4", :require => false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
31
36
|
appraise "railsNG" do
|
32
37
|
branch = ( ENV['rails_branch'] || 'master' )
|
33
38
|
gem "activerecord", :github => 'rails/rails', :branch => branch, :require => false
|
data/Gemfile
CHANGED
@@ -14,17 +14,13 @@ else
|
|
14
14
|
gem 'activerecord', :require => nil
|
15
15
|
end
|
16
16
|
|
17
|
-
# NOTE: gem overrides AR internals and assumes it can safely patch adapter classes ...
|
18
|
-
# thus it is to be used (in tests) as an optional - tests should roll fine without it!
|
19
|
-
gem 'composite_primary_keys', :require => nil unless ENV['COMPOSITE_PK'].eql?('false')
|
20
|
-
|
21
17
|
gem 'thread_safe', :require => nil # "optional" - we can roll without it
|
22
18
|
|
23
19
|
if defined?(JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
|
24
20
|
gem 'jruby-openssl', :platform => :jruby
|
25
21
|
end
|
26
22
|
|
27
|
-
gem 'rake',
|
23
|
+
gem 'rake', :require => nil
|
28
24
|
gem 'appraisal', '~> 0.5.2', :require => nil
|
29
25
|
|
30
26
|
# appraisal ignores group block declarations :
|
@@ -38,10 +34,10 @@ gem 'bcrypt-ruby', '~> 3.0.0', :require => nil, :group => :test
|
|
38
34
|
#gem 'trinidad_dbpool', :require => nil, :group => :test
|
39
35
|
|
40
36
|
group :development do
|
41
|
-
gem 'ruby-debug', :require => nil if ENV['DEBUG']
|
37
|
+
gem 'ruby-debug', :require => nil # if ENV['DEBUG']
|
42
38
|
group :doc do
|
43
39
|
gem 'yard', :require => nil
|
44
|
-
gem 'yard-method-overrides', :
|
40
|
+
gem 'yard-method-overrides', :git => 'https://github.com/kares/yard-method-overrides.git', :require => nil
|
45
41
|
gem 'kramdown', :require => nil
|
46
42
|
end
|
47
43
|
end
|
data/History.md
CHANGED
@@ -1,53 +1,3 @@
|
|
1
|
-
## 1.3.25 (08/22/18)
|
2
|
-
|
3
|
-
- [mysql] get rid of official driver < 5 checking on conn initialization
|
4
|
-
- [oracle] fix Oracle adapter not suing schema config properly (#869)
|
5
|
-
- [db2] refactor db2 quote (to avoid SQL injection) (#861)
|
6
|
-
- [db2] Fix a TypeError that happens when offset is used without limit (#873)
|
7
|
-
- [mssql] automatically remove identity columns from AR generated UPDATE (#872)
|
8
|
-
- [db2] Errors when dealing with blobs in jruby 9.2k (#902)
|
9
|
-
|
10
|
-
## 1.3.24 (09/24/17)
|
11
|
-
|
12
|
-
- [as400] Fixed ordering when limit and offset present (#789)
|
13
|
-
- [postgres] limit driver version correctly since > 9.4.1206 might break
|
14
|
-
- [db2] fixed issue with serialization not happening (#795)
|
15
|
-
resolves #725 (serialize with custom class not working on AR 4.2)
|
16
|
-
- reconnect!/disconnect! shall call super to reset cache/transaction state
|
17
|
-
- [oracle] some ~ enhanced adapter compatibility with configuration
|
18
|
-
- [mysql] support setting collation: xxx with config[:encoding] like AR 4.2
|
19
|
-
- [as400] Check if the exception thrown is a false-positive (#792)
|
20
|
-
- [as400] Added truncate functionality for DB2/AS400 (#793)
|
21
|
-
- [as400] Added DatabaseTasks for the as400 (#791)
|
22
|
-
|
23
|
-
## 1.3.23 (05/14/17)
|
24
|
-
|
25
|
-
- specify gem 'activerecord' < 5 since 5.x is not supported in 1.3.x
|
26
|
-
- [postgres] get non-seq id inserts working when insert_returning: false (#716)
|
27
|
-
- [postgres] previously-deprecated -i switch to pg_dump is no longer supported
|
28
|
-
(in PostgreSQL 9.5) (#729)
|
29
|
-
- [postgres] Assume that primary key can be multiple values (#773)
|
30
|
-
- prevent multiple pushes of the adapter file onto $LOADED_FEATURES
|
31
|
-
|
32
|
-
## 1.3.22 (12/23/16)
|
33
|
-
|
34
|
-
- [postgres] Fix incorrect postgresql_version when running RC (#717)
|
35
|
-
- [postgres] fixed insert into partitioned table (#723)
|
36
|
-
- [postgres] add ssl support from environment vars (#760)
|
37
|
-
- [postgres] Adds citext to AR42 Native database types (#746)
|
38
|
-
- [mysql] handle db:create failure compatibly with AR's MySQL tasks
|
39
|
-
- [mssql] Changed selects from information schema to uppercase
|
40
|
-
in case SQLServer database has case sensitive collation
|
41
|
-
- Added long varchar to type converter for legacy sybase DB (#757)
|
42
|
-
- [mysql] Don't read mysql binary column as stream (#742)
|
43
|
-
|
44
|
-
## 1.3.21 (08/18/16)
|
45
|
-
|
46
|
-
- check for instanceof RubyArray when extracting binds with stmnts
|
47
|
-
(for JRuby 9.1 packed array feature compatibility)
|
48
|
-
- default to useSSL=false for MariaDB driver
|
49
|
-
- [db2] allow to force zos: true using database config
|
50
|
-
|
51
1
|
## 1.3.20 (03/09/16)
|
52
2
|
|
53
3
|
- Retrieve AM::Type::Boolean::FALSE_VALUES for Rails 5 (#705)
|
data/RUNNING_TESTS.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
|
2
2
|
## Running AR-JDBC's Tests
|
3
3
|
|
4
|
+
After you have built arjdbc (run rake), then you can try testing it (if you
|
5
|
+
do not build then adapter_java.jar is not put into the lib dir). If you
|
6
|
+
change any of the .java files you will need to rebuild.
|
7
|
+
|
4
8
|
Most DB specific unit tests hide under the **test/db** directory, the files
|
5
9
|
included in the *test* directory are mostly shared test modules and helpers.
|
6
10
|
|
@@ -29,7 +29,8 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
30
30
|
gem.test_files = gem.files.grep(%r{^test/})
|
31
31
|
|
32
|
-
|
32
|
+
# NOTE: 1.3.0 only supports >= 2.3 but users report it works with 2.2 :
|
33
|
+
gem.add_dependency 'activerecord', '>= 2.2'
|
33
34
|
|
34
35
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
35
36
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module ArJdbc
|
2
|
+
# This is minimum amount of code neede from base JDBC Adapter class to make common adapters
|
3
|
+
# work. This replaces using jdbc/adapter as a base class for all adapters.
|
4
|
+
module CommonJdbcMethods
|
5
|
+
def initialize(connection, logger = nil, config = {})
|
6
|
+
config[:adapter_spec] = adapter_spec(config) unless config.key?(:adapter_spec)
|
7
|
+
|
8
|
+
connection ||= jdbc_connection_class(config[:adapter_spec]).new(config, self)
|
9
|
+
|
10
|
+
super(connection, logger, config)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Starts a database transaction.
|
14
|
+
# @override
|
15
|
+
def begin_db_transaction
|
16
|
+
@connection.begin
|
17
|
+
end
|
18
|
+
|
19
|
+
# Starts a database transaction.
|
20
|
+
# @param isolation the transaction isolation to use
|
21
|
+
def begin_isolated_db_transaction(isolation)
|
22
|
+
@connection.begin(isolation)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Commits the current database transaction.
|
26
|
+
# @override
|
27
|
+
def commit_db_transaction
|
28
|
+
@connection.commit
|
29
|
+
end
|
30
|
+
|
31
|
+
# Rolls back the current database transaction.
|
32
|
+
# @override
|
33
|
+
def exec_rollback_db_transaction
|
34
|
+
@connection.rollback
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def execute(sql, name = nil)
|
39
|
+
# FIXME: Can we kill :skip_logging?
|
40
|
+
if name == :skip_logging
|
41
|
+
@connection.execute(sql)
|
42
|
+
else
|
43
|
+
log(sql, name) { @connection.execute(sql) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Take an id from the result of an INSERT query.
|
48
|
+
# @return [Integer, NilClass]
|
49
|
+
def last_inserted_id(result)
|
50
|
+
if result.is_a?(Hash) || result.is_a?(ActiveRecord::Result)
|
51
|
+
result.first.first[1] # .first = { "id"=>1 } .first = [ "id", 1 ]
|
52
|
+
else
|
53
|
+
result
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Creates a (transactional) save-point one can rollback to.
|
58
|
+
# Unlike 'plain' `ActiveRecord` it is allowed to pass a save-point name.
|
59
|
+
# @param name the save-point name
|
60
|
+
# @return save-point name (even if nil passed will be generated)
|
61
|
+
# @since 1.3.0
|
62
|
+
# @extension added optional name parameter
|
63
|
+
def create_savepoint(name = current_savepoint_name(true))
|
64
|
+
@connection.create_savepoint(name)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Transaction rollback to a given (previously created) save-point.
|
68
|
+
# If no save-point name given rollback to the last created one.
|
69
|
+
# @param name the save-point name
|
70
|
+
# @extension added optional name parameter
|
71
|
+
def rollback_to_savepoint(name = current_savepoint_name(true))
|
72
|
+
@connection.rollback_savepoint(name)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Release a previously created save-point.
|
76
|
+
# @note Save-points are auto-released with the transaction they're created
|
77
|
+
# in (on transaction commit or roll-back).
|
78
|
+
# @param name the save-point name
|
79
|
+
# @extension added optional name parameter
|
80
|
+
def release_savepoint(name = current_savepoint_name(false))
|
81
|
+
@connection.release_savepoint(name)
|
82
|
+
end
|
83
|
+
|
84
|
+
# @private
|
85
|
+
def current_savepoint_name(compat = nil)
|
86
|
+
current_transaction.savepoint_name # unlike AR 3.2-4.1 might be nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/arjdbc/db2/adapter.rb
CHANGED
@@ -54,17 +54,6 @@ module ArJdbc
|
|
54
54
|
::ActiveRecord::ConnectionAdapters::DB2Column
|
55
55
|
end
|
56
56
|
|
57
|
-
# @see ActiveRecord::ConnectionAdapters::Jdbc::ArelSupport
|
58
|
-
def self.arel_visitor_type(config = nil)
|
59
|
-
require 'arel/visitors/db2'; ::Arel::Visitors::DB2
|
60
|
-
end
|
61
|
-
|
62
|
-
# @deprecated no longer used
|
63
|
-
# @see ActiveRecord::ConnectionAdapters::JdbcAdapter#arel2_visitors
|
64
|
-
def self.arel2_visitors(config)
|
65
|
-
{ 'db2' => arel_visitor_type }
|
66
|
-
end
|
67
|
-
|
68
57
|
# @private
|
69
58
|
@@emulate_booleans = true
|
70
59
|
|
@@ -356,49 +345,57 @@ module ArJdbc
|
|
356
345
|
# @param column (optional) contains info on the field
|
357
346
|
# @override
|
358
347
|
def quote(value, column = nil)
|
348
|
+
return value.quoted_id if value.respond_to?(:quoted_id)
|
359
349
|
return value if sql_literal?(value)
|
360
350
|
|
361
|
-
|
362
|
-
|
363
|
-
|
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
|
364
358
|
end
|
365
359
|
|
366
360
|
column_type = column && column.type.to_sym
|
367
361
|
|
368
362
|
case value
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
else
|
382
|
-
"BLOB('#{super}')"
|
383
|
-
end
|
384
|
-
elsif column && column.sql_type =~ /clob/ # :text
|
385
|
-
CLOB_VALUE_MARKER if update_lob_value?(value, column)# "'@@@IBMTEXT@@@'"
|
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@@@'"
|
386
375
|
else
|
387
|
-
|
376
|
+
"BLOB('#{quote_string(value)}')"
|
388
377
|
end
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
if column_type == :time
|
393
|
-
quote_time(value)
|
378
|
+
elsif column && column.sql_type =~ /clob/ # :text
|
379
|
+
if update_lob_value?(value, column)
|
380
|
+
value.nil? ? 'NULL' : CLOB_VALUE_MARKER # "'@@@IBMTEXT@@@'"
|
394
381
|
else
|
395
|
-
|
382
|
+
"'#{quote_string(value)}'"
|
396
383
|
end
|
397
|
-
|
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)
|
398
394
|
else
|
399
395
|
super
|
396
|
+
end
|
397
|
+
else super
|
400
398
|
end
|
401
|
-
|
402
399
|
end
|
403
400
|
|
404
401
|
# @override
|
@@ -484,26 +481,29 @@ module ArJdbc
|
|
484
481
|
|
485
482
|
# @private shared with {Arel::Visitors::DB2}
|
486
483
|
def replace_limit_offset!(sql, limit, offset, orders = nil)
|
487
|
-
|
484
|
+
limit = limit.to_i
|
485
|
+
|
486
|
+
if offset # && limit
|
487
|
+
over_order_by = nil # NOTE: orders matching got reverted as it was not complete and there were no case covering it ...
|
488
488
|
|
489
|
-
|
490
|
-
|
489
|
+
start_sql = "SELECT B.* FROM (SELECT A.*, row_number() OVER (#{over_order_by}) AS internal$rownum FROM (SELECT"
|
490
|
+
end_sql = ") A ) B WHERE B.internal$rownum > #{offset} AND B.internal$rownum <= #{limit + offset.to_i}"
|
491
491
|
|
492
|
-
|
493
|
-
|
492
|
+
if sql.is_a?(String)
|
493
|
+
sql.sub!(/SELECT/i, start_sql)
|
494
|
+
sql << end_sql
|
495
|
+
else # AR 4.2 sql.class ... Arel::Collectors::Bind
|
496
|
+
sql.parts[0] = start_sql # sql.sub! /SELECT/i
|
497
|
+
sql.parts[ sql.parts.length ] = end_sql
|
498
|
+
end
|
494
499
|
else
|
495
|
-
|
496
|
-
if
|
497
|
-
|
500
|
+
limit_sql = limit == 1 ? " FETCH FIRST ROW ONLY" : " FETCH FIRST #{limit} ROWS ONLY"
|
501
|
+
if sql.is_a?(String)
|
502
|
+
sql << limit_sql
|
503
|
+
else # AR 4.2 sql.class ... Arel::Collectors::Bind
|
504
|
+
sql.parts[ sql.parts.length ] = limit_sql
|
498
505
|
end
|
499
506
|
end
|
500
|
-
|
501
|
-
if sql.is_a?(String)
|
502
|
-
sql << param_sql
|
503
|
-
else # AR 4.2 sql.class ... Arel::Collectors::Bind
|
504
|
-
sql.parts[sql.parts.length] = param_sql
|
505
|
-
end
|
506
|
-
|
507
507
|
sql
|
508
508
|
end
|
509
509
|
|
@@ -568,7 +568,6 @@ module ArJdbc
|
|
568
568
|
end
|
569
569
|
|
570
570
|
def change_column_null(table_name, column_name, null)
|
571
|
-
raise NotImplementedError, "DB2 for zOS does not support changing the column's nullability" if zos?
|
572
571
|
if null
|
573
572
|
sql = "ALTER TABLE #{table_name} ALTER COLUMN #{column_name} DROP NOT NULL"
|
574
573
|
else
|
@@ -579,7 +578,6 @@ module ArJdbc
|
|
579
578
|
|
580
579
|
def change_column_default(table_name, column_name, default)
|
581
580
|
if default.nil?
|
582
|
-
raise NotImplementedError, "DB2 for zOS does not support changing the column default to NULL" if zos?
|
583
581
|
sql = "ALTER TABLE #{table_name} ALTER COLUMN #{column_name} DROP DEFAULT"
|
584
582
|
else
|
585
583
|
sql = "ALTER TABLE #{table_name} ALTER COLUMN #{column_name} SET WITH DEFAULT #{quote(default)}"
|
@@ -682,12 +680,6 @@ module ArJdbc
|
|
682
680
|
# @override
|
683
681
|
def supports_views?; true end
|
684
682
|
|
685
|
-
# @override
|
686
|
-
def supports_foreign_keys?; true end
|
687
|
-
|
688
|
-
# @override
|
689
|
-
def supports_ddl_transactions?; true end
|
690
|
-
|
691
683
|
def execute_table_change(sql, table_name, name = nil)
|
692
684
|
outcome = execute(sql, name)
|
693
685
|
reorg_table(table_name, name)
|
@@ -705,7 +697,7 @@ module ArJdbc
|
|
705
697
|
# Returns the value of an identity column of the last *INSERT* statement
|
706
698
|
# made over this connection.
|
707
699
|
# @note Check the *IDENTITY_VAL_LOCAL* function for documentation.
|
708
|
-
# @return [
|
700
|
+
# @return [Fixnum]
|
709
701
|
def last_insert_id
|
710
702
|
@connection.identity_val_local
|
711
703
|
end
|
@@ -734,14 +726,11 @@ module ArJdbc
|
|
734
726
|
|
735
727
|
# @private
|
736
728
|
def zos?
|
737
|
-
@zos =
|
729
|
+
@zos = nil unless defined? @zos
|
738
730
|
return @zos unless @zos.nil?
|
739
|
-
# jdbc:db2: - connection to a DB2 for z/OS, DB2 for Linux, UNIX, and Windows
|
740
|
-
# jdbc:db2j:net: - connection is to a remote IBM Cloudscape server
|
741
|
-
# jdbc:ids: - informix (not supported)
|
742
731
|
@zos =
|
743
732
|
if url = config[:url]
|
744
|
-
!!(
|
733
|
+
!!( url =~ /^jdbc:db2j:net:/ && config[:driver] == DRIVER_NAME )
|
745
734
|
else
|
746
735
|
nil
|
747
736
|
end
|