activerecord-jdbc-alt-adapter 70.1.0-java → 71.0.0.alpha1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +135 -21
- data/.github/workflows/ruby.yml +10 -10
- data/.gitignore +1 -0
- data/.solargraph.yml +15 -0
- data/Gemfile +17 -4
- data/README.md +7 -3
- data/RUNNING_TESTS.md +36 -0
- data/activerecord-jdbc-adapter.gemspec +2 -2
- data/activerecord-jdbc-alt-adapter.gemspec +1 -1
- data/lib/arel/visitors/sqlserver.rb +10 -0
- data/lib/arjdbc/abstract/connection_management.rb +23 -10
- data/lib/arjdbc/abstract/core.rb +5 -6
- data/lib/arjdbc/abstract/database_statements.rb +35 -25
- data/lib/arjdbc/abstract/statement_cache.rb +1 -6
- data/lib/arjdbc/abstract/transaction_support.rb +37 -9
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/column.rb +0 -34
- data/lib/arjdbc/jdbc/connection_methods.rb +1 -1
- data/lib/arjdbc/mssql/adapter.rb +93 -80
- data/lib/arjdbc/mssql/column.rb +1 -0
- data/lib/arjdbc/mssql/connection_methods.rb +7 -55
- data/lib/arjdbc/mssql/database_statements.rb +182 -71
- data/lib/arjdbc/mssql/explain_support.rb +8 -5
- data/lib/arjdbc/mssql/schema_creation.rb +1 -1
- data/lib/arjdbc/mssql/schema_definitions.rb +10 -0
- data/lib/arjdbc/mssql/schema_statements.rb +19 -11
- data/lib/arjdbc/mssql/server_version.rb +56 -0
- data/lib/arjdbc/mssql/utils.rb +23 -9
- data/lib/arjdbc/mysql/adapter.rb +64 -22
- data/lib/arjdbc/mysql/connection_methods.rb +43 -42
- data/lib/arjdbc/sqlite3/adapter.rb +218 -135
- data/lib/arjdbc/sqlite3/column.rb +103 -0
- data/lib/arjdbc/sqlite3/connection_methods.rb +7 -2
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +9 -5
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/02-test.rake +1 -1
- data/rakelib/rails.rake +2 -0
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +4 -2
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +2 -1
- metadata +11 -14
- data/lib/arel/visitors/sql_server/ng42.rb +0 -294
- data/lib/arel/visitors/sql_server.rb +0 -124
- data/lib/arjdbc/mssql/limit_helpers.rb +0 -231
- data/lib/arjdbc/mssql/lock_methods.rb +0 -77
- data/lib/arjdbc/mssql/old_adapter.rb +0 -804
- data/lib/arjdbc/mssql/old_column.rb +0 -200
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a773766cbb0e3ea279a04ab67b60c578382c604214c0a3dd5e54b7f419f4b96
|
4
|
+
data.tar.gz: d0f347ef628b4b791d81ad46a34d20f8ea3acb75cee3a473b2dbd8784769e897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c08cd49b3245c655a4c51d5c0d327cf7f058a7c2c98cedf7a59f00f60d14e7d79b1d9c2eef614712cee71b684f717fd6edd7c122fd0349d775a7e4fb2a48150
|
7
|
+
data.tar.gz: b1a059930367508754dc54ff2b8b76434991ac2897ea4ff4917a7ef540d25c28272c4c5cbe13f5b5215eded00940c9beece3f2415860a69b4621a7c62664fa02
|
data/.github/workflows/main.yml
CHANGED
@@ -27,7 +27,7 @@ jobs:
|
|
27
27
|
strategy:
|
28
28
|
fail-fast: false
|
29
29
|
matrix:
|
30
|
-
ruby-version: ['jruby-9.4.
|
30
|
+
ruby-version: ['jruby-9.4.8.0']
|
31
31
|
db: ['mssql']
|
32
32
|
test_targets: ['test_mssql']
|
33
33
|
|
@@ -68,18 +68,47 @@ jobs:
|
|
68
68
|
run: |
|
69
69
|
bundle exec rake ${{ matrix.test_targets }}
|
70
70
|
|
71
|
-
test-
|
71
|
+
test-arjdbc-sqlite:
|
72
72
|
|
73
|
-
name:
|
73
|
+
name: ARJDBC Tests (SQLite)
|
74
74
|
runs-on: ubuntu-latest
|
75
75
|
strategy:
|
76
76
|
fail-fast: false
|
77
77
|
matrix:
|
78
|
-
ruby-version: [
|
79
|
-
db: [
|
80
|
-
test_targets: [
|
81
|
-
|
82
|
-
|
78
|
+
ruby-version: ['jruby-9.4.8.0']
|
79
|
+
db: ['sqlite3']
|
80
|
+
test_targets: ['test_sqlite3']
|
81
|
+
|
82
|
+
env:
|
83
|
+
DB: ${{ matrix.db }}
|
84
|
+
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M --dev"
|
85
|
+
|
86
|
+
steps:
|
87
|
+
- uses: actions/checkout@v4
|
88
|
+
- name: Set up Ruby
|
89
|
+
uses: ruby/setup-ruby@v1
|
90
|
+
with:
|
91
|
+
ruby-version: ${{ matrix.ruby-version }}
|
92
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
93
|
+
- name: Build
|
94
|
+
run: |
|
95
|
+
rake jar
|
96
|
+
- name: Run tests
|
97
|
+
run: |
|
98
|
+
bundle exec rake ${{ matrix.test_targets }}
|
99
|
+
|
100
|
+
test-arjdbc-pgsql:
|
101
|
+
|
102
|
+
name: ARJDBC Tests (Postgres)
|
103
|
+
runs-on: ubuntu-latest
|
104
|
+
strategy:
|
105
|
+
fail-fast: false
|
106
|
+
matrix:
|
107
|
+
ruby-version: ['jruby-9.4.8.0']
|
108
|
+
db: ['postgresql']
|
109
|
+
test_targets: ["db:postgresql test_postgresql"]
|
110
|
+
prepared_statements: ['false', 'true']
|
111
|
+
insert_returning: ['false', 'true']
|
83
112
|
|
84
113
|
services:
|
85
114
|
postgres:
|
@@ -93,16 +122,64 @@ jobs:
|
|
93
122
|
|
94
123
|
env:
|
95
124
|
DB: ${{ matrix.db }}
|
96
|
-
AR_VERSION: ${{ matrix.ar_version }}
|
97
125
|
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
98
126
|
PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
|
99
|
-
|
127
|
+
INSERT_RETURNING: ${{ matrix.insert_returning }}
|
100
128
|
PGHOST: localhost
|
101
129
|
PGPORT: 5432
|
102
130
|
PGUSER: postgres
|
103
131
|
|
104
132
|
steps:
|
105
133
|
- uses: actions/checkout@v3
|
134
|
+
- name: Set up Ruby
|
135
|
+
uses: ruby/setup-ruby@v1
|
136
|
+
with:
|
137
|
+
ruby-version: ${{ matrix.ruby-version }}
|
138
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
139
|
+
- name: Build
|
140
|
+
run: |
|
141
|
+
rake jar
|
142
|
+
- name: Run tests
|
143
|
+
run: |
|
144
|
+
bundle exec rake ${{ matrix.test_targets }}
|
145
|
+
|
146
|
+
test-rails-mssql:
|
147
|
+
|
148
|
+
name: Rails Tests (mssql)
|
149
|
+
runs-on: ubuntu-latest
|
150
|
+
strategy:
|
151
|
+
fail-fast: false
|
152
|
+
matrix:
|
153
|
+
ruby-version: [ 'jruby-9.4.8.0' ]
|
154
|
+
db: [ 'mssql' ]
|
155
|
+
test_targets: [ "rails:test_mssql" ]
|
156
|
+
ar_version: ["7-1-stable-dev"]
|
157
|
+
|
158
|
+
services:
|
159
|
+
mssql:
|
160
|
+
image: mcr.microsoft.com/mssql/server:2019-latest
|
161
|
+
env:
|
162
|
+
ACCEPT_EULA: Y
|
163
|
+
MSSQL_SA_PASSWORD: Password12!
|
164
|
+
ports:
|
165
|
+
- 1433:1433
|
166
|
+
options: >-
|
167
|
+
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P \"Password12!\" -l 30 -Q \"SELECT 1\""
|
168
|
+
--health-start-period 10s
|
169
|
+
--health-interval 10s
|
170
|
+
--health-timeout 5s
|
171
|
+
--health-retries 10
|
172
|
+
|
173
|
+
env:
|
174
|
+
DB: ${{ matrix.db }}
|
175
|
+
AR_VERSION: ${{ matrix.ar_version }}
|
176
|
+
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
177
|
+
JDBC_SQLITE_VERSION: "3.32.3.3"
|
178
|
+
SQLUSER: SA
|
179
|
+
SQLPASS: Password12!
|
180
|
+
|
181
|
+
steps:
|
182
|
+
- uses: actions/checkout@v4
|
106
183
|
- name: Set up Ruby
|
107
184
|
uses: ruby/setup-ruby@v1
|
108
185
|
with:
|
@@ -110,8 +187,8 @@ jobs:
|
|
110
187
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
111
188
|
- name: Setup database
|
112
189
|
run: |
|
113
|
-
|
114
|
-
|
190
|
+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE jdbc_arunit;"
|
191
|
+
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password12!" -Q "CREATE DATABASE jdbc_arunit2;"
|
115
192
|
- name: Build
|
116
193
|
run: |
|
117
194
|
rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
|
@@ -119,18 +196,50 @@ jobs:
|
|
119
196
|
run: |
|
120
197
|
bundle exec rake ${{ matrix.test_targets }}
|
121
198
|
|
122
|
-
test-
|
199
|
+
test-rails-sqlite:
|
123
200
|
|
124
|
-
name:
|
201
|
+
name: Rails Tests (SQLite)
|
125
202
|
runs-on: ubuntu-latest
|
126
203
|
strategy:
|
127
204
|
fail-fast: false
|
128
205
|
matrix:
|
129
|
-
ruby-version: ['jruby-9.4.
|
130
|
-
db: ['
|
131
|
-
test_targets: ["
|
132
|
-
|
133
|
-
|
206
|
+
ruby-version: ['jruby-9.4.8.0']
|
207
|
+
db: ['sqlite3']
|
208
|
+
test_targets: ["rails:test_sqlite3"]
|
209
|
+
ar_version: ["7-1-stable"]
|
210
|
+
|
211
|
+
env:
|
212
|
+
DB: ${{ matrix.db }}
|
213
|
+
AR_VERSION: ${{ matrix.ar_version }}
|
214
|
+
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
215
|
+
|
216
|
+
steps:
|
217
|
+
- uses: actions/checkout@v4
|
218
|
+
- name: Set up Ruby
|
219
|
+
uses: ruby/setup-ruby@v1
|
220
|
+
with:
|
221
|
+
ruby-version: ${{ matrix.ruby-version }}
|
222
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
223
|
+
- name: Build
|
224
|
+
run: |
|
225
|
+
echo "JAVA_OPTS=$JAVA_OPTS"
|
226
|
+
rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
|
227
|
+
- name: Run tests
|
228
|
+
run: |
|
229
|
+
bundle exec rake ${{ matrix.test_targets }}
|
230
|
+
|
231
|
+
test-rails-pgsql:
|
232
|
+
|
233
|
+
name: Rails Tests (Postgres)
|
234
|
+
runs-on: ubuntu-latest
|
235
|
+
strategy:
|
236
|
+
fail-fast: false
|
237
|
+
matrix:
|
238
|
+
ruby-version: [ 'jruby-9.4.8.0' ]
|
239
|
+
db: [ 'postgresql' ]
|
240
|
+
test_targets: [ "rails:test_postgresql" ]
|
241
|
+
ar_version: ["7-1-stable"]
|
242
|
+
prepared_statements: [ 'false', 'true' ]
|
134
243
|
|
135
244
|
services:
|
136
245
|
postgres:
|
@@ -144,9 +253,10 @@ jobs:
|
|
144
253
|
|
145
254
|
env:
|
146
255
|
DB: ${{ matrix.db }}
|
256
|
+
AR_VERSION: ${{ matrix.ar_version }}
|
147
257
|
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
148
258
|
PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
|
149
|
-
|
259
|
+
JDBC_SQLITE_VERSION: "3.32.3.3"
|
150
260
|
PGHOST: localhost
|
151
261
|
PGPORT: 5432
|
152
262
|
PGUSER: postgres
|
@@ -158,9 +268,13 @@ jobs:
|
|
158
268
|
with:
|
159
269
|
ruby-version: ${{ matrix.ruby-version }}
|
160
270
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
271
|
+
- name: Setup database
|
272
|
+
run: |
|
273
|
+
psql -c "create database activerecord_unittest;" -U postgres
|
274
|
+
psql -c "create database activerecord_unittest2;" -U postgres
|
161
275
|
- name: Build
|
162
276
|
run: |
|
163
|
-
rake jar
|
277
|
+
rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
|
164
278
|
- name: Run tests
|
165
279
|
run: |
|
166
280
|
bundle exec rake ${{ matrix.test_targets }}
|
data/.github/workflows/ruby.yml
CHANGED
@@ -27,7 +27,7 @@ jobs:
|
|
27
27
|
ruby-version: ['jruby-head']
|
28
28
|
db: ['mysql2']
|
29
29
|
test_targets: ["rails:test_mysql2"]
|
30
|
-
ar_version: ["7-
|
30
|
+
ar_version: ["7-1-stable"]
|
31
31
|
prepared_statements: ['false', 'true']
|
32
32
|
driver: ['MySQL']
|
33
33
|
|
@@ -45,7 +45,7 @@ jobs:
|
|
45
45
|
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
46
46
|
|
47
47
|
steps:
|
48
|
-
- uses: actions/checkout@
|
48
|
+
- uses: actions/checkout@v4
|
49
49
|
- name: Set up Ruby
|
50
50
|
uses: ruby/setup-ruby@v1
|
51
51
|
with:
|
@@ -79,7 +79,7 @@ jobs:
|
|
79
79
|
ruby-version: [ 'jruby-head' ]
|
80
80
|
db: [ 'postgresql' ]
|
81
81
|
test_targets: [ "rails:test_postgresql" ]
|
82
|
-
ar_version: ["7-
|
82
|
+
ar_version: ["7-1-stable"]
|
83
83
|
prepared_statements: [ 'false', 'true' ]
|
84
84
|
|
85
85
|
services:
|
@@ -102,7 +102,7 @@ jobs:
|
|
102
102
|
PGUSER: postgres
|
103
103
|
|
104
104
|
steps:
|
105
|
-
- uses: actions/checkout@
|
105
|
+
- uses: actions/checkout@v4
|
106
106
|
- name: Set up Ruby
|
107
107
|
uses: ruby/setup-ruby@v1
|
108
108
|
with:
|
@@ -129,7 +129,7 @@ jobs:
|
|
129
129
|
ruby-version: ['jruby-head']
|
130
130
|
db: ['sqlite3']
|
131
131
|
test_targets: ["rails:test_sqlite3"]
|
132
|
-
ar_version: ["7-
|
132
|
+
ar_version: ["7-1-stable", "main"]
|
133
133
|
|
134
134
|
env:
|
135
135
|
DB: ${{ matrix.db }}
|
@@ -137,7 +137,7 @@ jobs:
|
|
137
137
|
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
138
138
|
|
139
139
|
steps:
|
140
|
-
- uses: actions/checkout@
|
140
|
+
- uses: actions/checkout@v4
|
141
141
|
- name: Set up Ruby
|
142
142
|
uses: ruby/setup-ruby@v1
|
143
143
|
with:
|
@@ -179,7 +179,7 @@ jobs:
|
|
179
179
|
PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
|
180
180
|
|
181
181
|
steps:
|
182
|
-
- uses: actions/checkout@
|
182
|
+
- uses: actions/checkout@v4
|
183
183
|
- name: Set up Ruby
|
184
184
|
uses: ruby/setup-ruby@v1
|
185
185
|
with:
|
@@ -230,7 +230,7 @@ jobs:
|
|
230
230
|
PGUSER: postgres
|
231
231
|
|
232
232
|
steps:
|
233
|
-
- uses: actions/checkout@
|
233
|
+
- uses: actions/checkout@v4
|
234
234
|
- name: Set up Ruby
|
235
235
|
uses: ruby/setup-ruby@v1
|
236
236
|
with:
|
@@ -256,10 +256,10 @@ jobs:
|
|
256
256
|
|
257
257
|
env:
|
258
258
|
DB: ${{ matrix.db }}
|
259
|
-
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M"
|
259
|
+
JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M --dev"
|
260
260
|
|
261
261
|
steps:
|
262
|
-
- uses: actions/checkout@
|
262
|
+
- uses: actions/checkout@v4
|
263
263
|
- name: Set up Ruby
|
264
264
|
uses: ruby/setup-ruby@v1
|
265
265
|
with:
|
data/.gitignore
CHANGED
data/.solargraph.yml
ADDED
data/Gemfile
CHANGED
@@ -34,17 +34,24 @@ elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
|
|
34
34
|
opts = {branch: version}
|
35
35
|
end
|
36
36
|
|
37
|
-
git 'https://github.com/
|
37
|
+
git 'https://github.com/JesseChavez/rails.git', **opts do
|
38
38
|
gem 'activerecord', require: false
|
39
39
|
gem 'activemodel', require: false
|
40
40
|
gem 'activesupport', require: false
|
41
41
|
gem 'actionpack', require: false
|
42
42
|
gem 'actionview', require: false
|
43
43
|
end
|
44
|
+
|
44
45
|
end
|
45
46
|
end
|
46
47
|
else
|
47
|
-
|
48
|
+
if defined? JRUBY_VERSION
|
49
|
+
gemspec name: 'activerecord-jdbc-alt-adapter' # Use versiom from .gemspec
|
50
|
+
else # read add_dependency 'activerecord', '~> 7.0' and use the same requirement on MRI
|
51
|
+
ar_req = File.read('activerecord-jdbc-adapter.gemspec').match(/add_dependency.*?activerecord.*['"](.*?)['"]/)[1]
|
52
|
+
raise "add_dependency 'activerecord', ... line not detected in gemspec" unless ar_req
|
53
|
+
gem 'activerecord', ar_req
|
54
|
+
end
|
48
55
|
end
|
49
56
|
|
50
57
|
gem 'rake', require: nil
|
@@ -72,6 +79,10 @@ group :rails do
|
|
72
79
|
gem 'builder', require: nil
|
73
80
|
|
74
81
|
gem 'erubis', require: nil # "~> 2.7.0"
|
82
|
+
|
83
|
+
# Due to rails/activesupport/lib/active_support/message_pack.rb
|
84
|
+
gem 'msgpack', '>= 1.7.0', require: false
|
85
|
+
|
75
86
|
# NOTE: due rails/activerecord/test/cases/connection_management_test.rb
|
76
87
|
gem 'rack', require: nil
|
77
88
|
|
@@ -79,7 +90,7 @@ group :rails do
|
|
79
90
|
end
|
80
91
|
|
81
92
|
group :development do
|
82
|
-
gem 'ruby-debug', require: nil # if ENV['DEBUG']
|
93
|
+
#gem 'ruby-debug', require: nil # if ENV['DEBUG']
|
83
94
|
group :doc do
|
84
95
|
gem 'yard', require: nil
|
85
96
|
gem 'kramdown', require: nil
|
@@ -94,10 +105,12 @@ group :test do
|
|
94
105
|
|
95
106
|
gem 'mysql2', '>= 0.4.4', require: nil, platform: :mri
|
96
107
|
gem 'pg', '>= 0.18.0', require: nil, platform: :mri
|
97
|
-
gem 'sqlite3', '~> 1.
|
108
|
+
gem 'sqlite3', '~> 1.4', require: nil, platform: :mri
|
98
109
|
|
99
110
|
# group :mssql do
|
100
111
|
# gem 'tiny_tds', require: nil, platform: :mri
|
101
112
|
# gem 'activerecord-sqlserver-adapter', require: nil, platform: :mri
|
102
113
|
# end
|
103
114
|
end
|
115
|
+
|
116
|
+
gem 'pry-nav'
|
data/README.md
CHANGED
@@ -143,10 +143,14 @@ Versions are targeted at certain versions of Rails and live on their own branche
|
|
143
143
|
| 51.x | 5.1.x | 51-stable | 9.1.x | 7 |
|
144
144
|
| 52.x | 5.2.x | 52-stable | 9.1.x | 7 |
|
145
145
|
| 60.x | 6.0.x | 60-stable | 9.2.7 | 8 |
|
146
|
-
| 61.x | 6.1.x |
|
146
|
+
| 61.x | 6.1.x | 61-stable | 9.2.7 | 8 |
|
147
|
+
| 70.x | 7.0.x | 70-stable | 9.3.0 | 8 |
|
148
|
+
| 71.x | 7.1.x | master | 9.4.3 | 8 |
|
147
149
|
|
148
|
-
Note
|
149
|
-
|
150
|
+
Note: 71.x is still under development and not supported yet.
|
151
|
+
|
152
|
+
Note that JRuby 9.1.x and JRuby 9.2.x are at end-of-life. We recommend Java 8
|
153
|
+
at a minimum for all versions.
|
150
154
|
|
151
155
|
## Using ActiveRecord JDBC
|
152
156
|
|
data/RUNNING_TESTS.md
CHANGED
@@ -16,6 +16,8 @@ Rake tasks are loaded from **rakelib/02-test-rake**, most adapters have a
|
|
16
16
|
corresponding test_[adapter] task e.g. `rake test_sqlite3` that run against DB.
|
17
17
|
To check all available (test related) tasks simply `rake -T | grep test`.
|
18
18
|
|
19
|
+
### Database Setup
|
20
|
+
|
19
21
|
If the adapter supports creating a database it will try to do so automatically
|
20
22
|
(most embed databases such as SQLite3) for some adapters (MySQL, PostgreSQL) we
|
21
23
|
do this auto-magically (see the `rake db:create` tasks), but otherwise you'll
|
@@ -48,6 +50,40 @@ but one can easily run tests with prepared statements disabled using env vars :
|
|
48
50
|
|
49
51
|
rake test_derby PREPARED_STATEMENTS=false
|
50
52
|
|
53
|
+
#### MySQL with Docker
|
54
|
+
|
55
|
+
The standard Docker MySQL image can be used for testing and development. Depending on your environment these commands
|
56
|
+
may need to be run as root.
|
57
|
+
|
58
|
+
Pull the image:
|
59
|
+
|
60
|
+
```
|
61
|
+
sudo docker pull mysql
|
62
|
+
```
|
63
|
+
|
64
|
+
Start up the database with a root password (we show a simple one here but pick one no one else knows):
|
65
|
+
|
66
|
+
```
|
67
|
+
docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=testtest9 -d mysql
|
68
|
+
```
|
69
|
+
|
70
|
+
The `mysql` client can be run through Docker as well:
|
71
|
+
|
72
|
+
```sh
|
73
|
+
docker run -it --link mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
|
74
|
+
```
|
75
|
+
|
76
|
+
Set up the database for the unit tests (you may need to replace 'localhost' with your container's IP):
|
77
|
+
|
78
|
+
```sql
|
79
|
+
CREATE USER 'rails'@'localhost' IDENTIFIED BY 'testtest9';
|
80
|
+
CREATE DATABASE activerecord_unittest;
|
81
|
+
GRANT ALL PRIVILEGES ON activerecord_unittest.* TO 'rails'@'localhost';
|
82
|
+
CREATE DATABASE activerecord_unittest2;
|
83
|
+
GRANT ALL PRIVILEGES ON activerecord_unittest2.* TO 'rails'@'localhost';
|
84
|
+
```
|
85
|
+
|
86
|
+
Then edit test/rails/config.yml for the appropriate configuration credentials.
|
51
87
|
|
52
88
|
### ActiveRecord (Rails) Tests
|
53
89
|
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
"AR-JDBC is a database adapter for Rails' ActiveRecord component " <<
|
15
15
|
"designed to be used with JRuby built upon Java's JDBC API for " <<
|
16
16
|
"database access. Provides (ActiveRecord) built-in adapters: MySQL, " <<
|
17
|
-
"PostgreSQL,
|
17
|
+
"PostgreSQL, and SQLite3."
|
18
18
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |gem|
|
|
41
41
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
42
42
|
gem.test_files = gem.files.grep(%r{^test/})
|
43
43
|
|
44
|
-
gem.add_dependency 'activerecord', '~> 7.0'
|
44
|
+
gem.add_dependency 'activerecord', '~> 7.1.0'
|
45
45
|
|
46
46
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
47
47
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
43
43
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
44
44
|
gem.test_files = gem.files.grep(%r{^test/})
|
45
45
|
|
46
|
-
gem.add_dependency 'activerecord', '~> 7.
|
46
|
+
gem.add_dependency 'activerecord', '~> 7.1.3'
|
47
47
|
|
48
48
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
49
49
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
@@ -51,6 +51,16 @@ module Arel
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
# Override the default in arel ToSql class
|
55
|
+
def visit_Arel_Nodes_NullsFirst(o, collector)
|
56
|
+
visit o.expr, collector
|
57
|
+
end
|
58
|
+
|
59
|
+
# Override the default in arel ToSql class
|
60
|
+
def visit_Arel_Nodes_NullsLast(o, collector)
|
61
|
+
visit o.expr, collector
|
62
|
+
end
|
63
|
+
|
54
64
|
def visit_Arel_Nodes_Grouping(o, collector)
|
55
65
|
remove_invalid_ordering_from_select_statement(o.expr)
|
56
66
|
super
|
@@ -6,29 +6,28 @@ module ArJdbc
|
|
6
6
|
|
7
7
|
# @override
|
8
8
|
def active?
|
9
|
-
|
10
|
-
@connection.active?
|
9
|
+
@raw_connection&.active?
|
11
10
|
end
|
12
11
|
|
13
12
|
def really_valid?
|
14
|
-
|
15
|
-
@connection.really_valid?
|
13
|
+
@raw_connection&.really_valid?
|
16
14
|
end
|
17
15
|
|
18
16
|
# @override
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
# Removed to fix sqlite adapter, may be needed for others
|
18
|
+
# def reconnect!
|
19
|
+
# super # clear_cache! && reset_transaction
|
20
|
+
# @connection.reconnect! # handles adapter.configure_connection
|
21
|
+
# end
|
23
22
|
|
24
23
|
# @override
|
25
24
|
def disconnect!
|
26
25
|
super # clear_cache! && reset_transaction
|
27
|
-
|
28
|
-
@connection.disconnect!
|
26
|
+
@raw_connection&.disconnect!
|
29
27
|
end
|
30
28
|
|
31
29
|
# @override
|
30
|
+
# Removed to fix sqlite adapter, may be needed for others
|
32
31
|
# def verify!(*ignored)
|
33
32
|
# if @connection && @connection.jndi?
|
34
33
|
# # checkout call-back does #reconnect!
|
@@ -37,6 +36,20 @@ module ArJdbc
|
|
37
36
|
# end
|
38
37
|
# end
|
39
38
|
|
39
|
+
# DIFFERENCE: we delve into jdbc shared code and this does self.class.new_client.
|
40
|
+
def connect
|
41
|
+
@raw_connection = jdbc_connection_class(@config[:adapter_spec]).new(@config, self)
|
42
|
+
@raw_connection.configure_connection
|
43
|
+
end
|
44
|
+
|
45
|
+
def reconnect
|
46
|
+
if active?
|
47
|
+
@raw_connection.rollback rescue nil
|
48
|
+
else
|
49
|
+
connect
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
40
53
|
end
|
41
54
|
end
|
42
55
|
end
|
data/lib/arjdbc/abstract/core.rb
CHANGED
@@ -9,7 +9,7 @@ module ArJdbc
|
|
9
9
|
|
10
10
|
attr_reader :config
|
11
11
|
|
12
|
-
def initialize(
|
12
|
+
def initialize(config)
|
13
13
|
@config = config
|
14
14
|
|
15
15
|
if self.class.equal? ActiveRecord::ConnectionAdapters::JdbcAdapter
|
@@ -18,11 +18,7 @@ module ArJdbc
|
|
18
18
|
extend spec if spec
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
super(connection, logger, config) # AbstractAdapter
|
24
|
-
|
25
|
-
connection.configure_connection # will call us (maybe)
|
21
|
+
super(config) # AbstractAdapter
|
26
22
|
end
|
27
23
|
|
28
24
|
# Retrieve the raw `java.sql.Connection` object.
|
@@ -56,6 +52,9 @@ module ArJdbc
|
|
56
52
|
# swallow an ArJdbc / driver bug into an AR::StatementInvalid !
|
57
53
|
return exception if exception.is_a?(Throwable)
|
58
54
|
|
55
|
+
# We create this exception in Java where we do not have access to the pool
|
56
|
+
exception.instance_variable_set(:@connection_pool, @pool) if exception.kind_of?(::ActiveRecord::JDBCError)
|
57
|
+
|
59
58
|
case exception
|
60
59
|
when SystemExit, SignalException, NoMemoryError then exception
|
61
60
|
when ActiveModel::RangeError, TypeError, RuntimeError then exception
|