activerecord-jdbc-adapter 72.0-java → 80.0.pre1-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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +129 -24
  3. data/.mise.toml +3 -0
  4. data/Gemfile +42 -47
  5. data/README.md +3 -2
  6. data/Rakefile +62 -14
  7. data/activerecord-jdbc-adapter.gemspec +2 -2
  8. data/lib/arjdbc/abstract/core.rb +1 -1
  9. data/lib/arjdbc/abstract/database_statements.rb +11 -7
  10. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  11. data/lib/arjdbc/postgresql/adapter.rb +4 -1
  12. data/lib/arjdbc/sqlite3/adapter.rb +48 -7
  13. data/lib/arjdbc/version.rb +1 -1
  14. data/pom.xml +3 -3
  15. data/rakelib/db.rake +5 -3
  16. data/rakelib/rails.rake +0 -1
  17. data/src/java/arjdbc/ArJdbcModule.java +13 -10
  18. data/src/java/arjdbc/db2/DB2Module.java +4 -4
  19. data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +8 -9
  20. data/src/java/arjdbc/h2/H2Module.java +2 -1
  21. data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +8 -7
  22. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +5 -6
  23. data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +4 -3
  24. data/src/java/arjdbc/jdbc/DriverWrapper.java +13 -8
  25. data/src/java/arjdbc/jdbc/JdbcResult.java +10 -7
  26. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +168 -154
  27. data/src/java/arjdbc/mssql/MSSQLModule.java +3 -3
  28. data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +13 -9
  29. data/src/java/arjdbc/mysql/MySQLModule.java +3 -3
  30. data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +30 -24
  31. data/src/java/arjdbc/oracle/OracleModule.java +2 -3
  32. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +22 -18
  33. data/src/java/arjdbc/postgresql/PostgreSQLModule.java +2 -3
  34. data/src/java/arjdbc/postgresql/PostgreSQLResult.java +24 -12
  35. data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +16 -12
  36. data/src/java/arjdbc/sqlite3/SQLite3Module.java +2 -3
  37. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +78 -29
  38. data/src/java/arjdbc/util/DateTimeUtils.java +7 -5
  39. data/src/java/arjdbc/util/ObjectSupport.java +2 -2
  40. data/src/java/arjdbc/util/StringHelper.java +1 -1
  41. metadata +6 -6
  42. data/.travis.yml +0 -128
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1b3740f2a2d3d25cd4ab6bf0538e3848717ac46b27f793d67b876b424a9cd02
4
- data.tar.gz: b55adb9d8ce1abbfc66c2d2ea17e70f861a877d673ada18898230503bb740ba8
3
+ metadata.gz: 126f20bb7b8403ad8a284fd75f73d0141039f68f10e3488a0be36da6e31d1307
4
+ data.tar.gz: '09f8725e1f8a28d4b9cb8e01a4fb07f419727ec9dfc561740ec52e2b56b6e2dd'
5
5
  SHA512:
6
- metadata.gz: a8c590ce9f1fda81cb270a53e8ddb07f21c46bd757ea11f6e8ee196486cdcdb843131230128cf1351787caaaa9f5a76291e33fb265b80f16128c7e0a4482187e
7
- data.tar.gz: '0479e365e2de0b5f866acd5872e41a96f693bd85c82fc0758a38cc03b365e9a93e3e3124d011fe214b9bb54e3317d17688d752aed18ad152b8035dec8b688462'
6
+ metadata.gz: 1615999867c54b179d94ab833100320af6c6b3be80a3a1f1991ab2efb4cb1c586818b6d0b88a3e1103be50bfa357feb52551543a0be1e81b43d8e6b47d90039e
7
+ data.tar.gz: 17bef2d1991fb4eeb5fd53011e16dba1ce5056742fb82311bddd31455d99de20d70b9fb3a43fac0b35e547827f100b1d12f369a916a1461bf82a5c911a3b531a
@@ -7,11 +7,7 @@
7
7
 
8
8
  name: Ruby
9
9
 
10
- on:
11
- push:
12
- branches: [ master, 72-stable ]
13
- pull_request:
14
- branches: [ master, 72-stable ]
10
+ on: [push, pull_request]
15
11
 
16
12
  permissions:
17
13
  contents: read
@@ -24,16 +20,16 @@ jobs:
24
20
  strategy:
25
21
  fail-fast: false
26
22
  matrix:
27
- ruby-version: ['jruby-9.4.14.0']
23
+ ruby-version: ['jruby-head']
28
24
  db: ['mysql2']
29
25
  test_targets: ["rails:test_mysql2"]
30
- ar_version: ["7-2-stable"]
26
+ ar_version: ["8-0-stable"]
31
27
  prepared_statements: ['false', 'true']
32
28
  driver: ['MySQL']
33
29
 
34
30
  services:
35
31
  mysql:
36
- image: mysql:5.7
32
+ image: mysql:8
37
33
  ports:
38
34
  - 3306
39
35
 
@@ -46,11 +42,19 @@ jobs:
46
42
 
47
43
  steps:
48
44
  - uses: actions/checkout@v4
45
+ - name: Set up Java 21
46
+ uses: actions/setup-java@v4
47
+ with:
48
+ distribution: 'temurin'
49
+ java-version: '21'
49
50
  - name: Set up Ruby
50
51
  uses: ruby/setup-ruby@v1
51
52
  with:
52
53
  ruby-version: ${{ matrix.ruby-version }}
53
54
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
55
+ - name: Setup gdiff
56
+ run: |
57
+ sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
54
58
  - name: Setup database
55
59
  run: |
56
60
  sudo service mysql start
@@ -76,18 +80,18 @@ jobs:
76
80
  strategy:
77
81
  fail-fast: false
78
82
  matrix:
79
- ruby-version: [ 'jruby-9.4.14.0' ]
83
+ ruby-version: [ 'jruby-head' ]
80
84
  db: [ 'postgresql' ]
81
85
  test_targets: [ "rails:test_postgresql" ]
82
- ar_version: ["7-2-stable"]
86
+ ar_version: ["8-0-stable"]
83
87
  prepared_statements: [ 'false', 'true' ]
84
88
 
85
89
  services:
86
90
  postgres:
87
- image: postgres:11
91
+ image: postgres:17
88
92
  env:
89
93
  POSTGRES_PASSWORD: postgres
90
- POSTGRES_HOST_AUTH_METHOD: trust
94
+ POSTGRES_DB: postgres
91
95
  ports:
92
96
  - 5432:5432
93
97
  options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
@@ -99,19 +103,38 @@ jobs:
99
103
  PREPARED_STATEMENTS: ${{ matrix.prepared_statements }}
100
104
  PGHOST: localhost
101
105
  PGPORT: 5432
102
- PGUSER: postgres
106
+ PGUSER: arjdbc
107
+ PGPASSWORD: arjdbc
103
108
 
104
109
  steps:
105
110
  - uses: actions/checkout@v4
111
+ - name: Set up Java 21
112
+ uses: actions/setup-java@v4
113
+ with:
114
+ distribution: 'temurin'
115
+ java-version: '21'
106
116
  - name: Set up Ruby
107
117
  uses: ruby/setup-ruby@v1
108
118
  with:
109
119
  ruby-version: ${{ matrix.ruby-version }}
110
120
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
121
+ - name: Install PostgreSQL 17 client
122
+ run: |
123
+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
124
+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
125
+ sudo apt-get update
126
+ sudo apt-get install -y postgresql-client-17
127
+ - name: Setup gdiff
128
+ run: |
129
+ sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
111
130
  - name: Setup database
112
131
  run: |
113
- psql -c "create database activerecord_unittest;" -U postgres
114
- psql -c "create database activerecord_unittest2;" -U postgres
132
+ PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER arjdbc WITH SUPERUSER CREATEDB LOGIN PASSWORD 'arjdbc';"
133
+ echo "Testing connection as arjdbc user..."
134
+ PGPASSWORD=arjdbc psql -h localhost -d postgres -U arjdbc -c '\l'
135
+ echo "Exit status: $?"
136
+ PGPASSWORD=arjdbc psql -h localhost -d postgres -c "create database activerecord_unittest;" -U arjdbc
137
+ PGPASSWORD=arjdbc psql -h localhost -d postgres -c "create database activerecord_unittest2;" -U arjdbc
115
138
  - name: Build
116
139
  run: |
117
140
  rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
@@ -126,10 +149,10 @@ jobs:
126
149
  strategy:
127
150
  fail-fast: false
128
151
  matrix:
129
- ruby-version: ['jruby-9.4.14.0']
152
+ ruby-version: ['jruby-head']
130
153
  db: ['sqlite3']
131
154
  test_targets: ["rails:test_sqlite3"]
132
- ar_version: ["7-2-stable"]
155
+ ar_version: ["8-0-stable"]
133
156
 
134
157
  env:
135
158
  DB: ${{ matrix.db }}
@@ -138,11 +161,19 @@ jobs:
138
161
 
139
162
  steps:
140
163
  - uses: actions/checkout@v4
164
+ - name: Set up Java 21
165
+ uses: actions/setup-java@v4
166
+ with:
167
+ distribution: 'temurin'
168
+ java-version: '21'
141
169
  - name: Set up Ruby
142
170
  uses: ruby/setup-ruby@v1
143
171
  with:
144
172
  ruby-version: ${{ matrix.ruby-version }}
145
173
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
174
+ - name: Setup gdiff
175
+ run: |
176
+ sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
146
177
  - name: Build
147
178
  run: |
148
179
  echo "JAVA_OPTS=$JAVA_OPTS"
@@ -158,7 +189,7 @@ jobs:
158
189
  strategy:
159
190
  fail-fast: false
160
191
  matrix:
161
- ruby-version: ['jruby-9.4.14.0']
192
+ ruby-version: ['jruby-head']
162
193
  db: ['mysql2']
163
194
  test_targets: ["db:mysql test_mysql2"]
164
195
  prepared_statements: ['false', 'true']
@@ -166,7 +197,7 @@ jobs:
166
197
 
167
198
  services:
168
199
  mysql:
169
- image: mysql:5.7
200
+ image: mysql:8
170
201
  ports:
171
202
  - 3306
172
203
 
@@ -180,6 +211,11 @@ jobs:
180
211
 
181
212
  steps:
182
213
  - uses: actions/checkout@v4
214
+ - name: Set up Java 21
215
+ uses: actions/setup-java@v4
216
+ with:
217
+ distribution: 'temurin'
218
+ java-version: '21'
183
219
  - name: Set up Ruby
184
220
  uses: ruby/setup-ruby@v1
185
221
  with:
@@ -203,7 +239,7 @@ jobs:
203
239
  strategy:
204
240
  fail-fast: false
205
241
  matrix:
206
- ruby-version: ['jruby-9.4.14.0']
242
+ ruby-version: ['jruby-head']
207
243
  db: ['postgresql']
208
244
  test_targets: ["db:postgresql test_postgresql"]
209
245
  prepared_statements: ['false', 'true']
@@ -211,10 +247,10 @@ jobs:
211
247
 
212
248
  services:
213
249
  postgres:
214
- image: postgres:11
250
+ image: postgres:17
215
251
  env:
216
252
  POSTGRES_PASSWORD: postgres
217
- POSTGRES_HOST_AUTH_METHOD: trust
253
+ POSTGRES_DB: postgres
218
254
  ports:
219
255
  - 5432:5432
220
256
  options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
@@ -227,15 +263,35 @@ jobs:
227
263
  INSERT_RETURNING: ${{ matrix.insert_returning }}
228
264
  PGHOST: localhost
229
265
  PGPORT: 5432
230
- PGUSER: postgres
266
+ PGUSER: arjdbc
267
+ PGPASSWORD: arjdbc
231
268
 
232
269
  steps:
233
270
  - uses: actions/checkout@v4
271
+ - name: Set up Java 21
272
+ uses: actions/setup-java@v4
273
+ with:
274
+ distribution: 'temurin'
275
+ java-version: '21'
234
276
  - name: Set up Ruby
235
277
  uses: ruby/setup-ruby@v1
236
278
  with:
237
279
  ruby-version: ${{ matrix.ruby-version }}
238
280
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
281
+ - name: Install PostgreSQL 17 client
282
+ run: |
283
+ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
284
+ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
285
+ sudo apt-get update
286
+ sudo apt-get install -y postgresql-client-17
287
+ - name: Setup PostgreSQL user
288
+ run: |
289
+ PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER arjdbc WITH SUPERUSER CREATEDB LOGIN PASSWORD 'arjdbc';"
290
+ - name: Test PostgreSQL connection
291
+ run: |
292
+ echo "Testing connection as arjdbc user..."
293
+ PGPASSWORD=arjdbc psql -h localhost -d postgres -U arjdbc -c '\l'
294
+ echo "Exit status: $?"
239
295
  - name: Build
240
296
  run: |
241
297
  rake jar
@@ -250,7 +306,7 @@ jobs:
250
306
  strategy:
251
307
  fail-fast: false
252
308
  matrix:
253
- ruby-version: ['jruby-9.4.14.0']
309
+ ruby-version: ['jruby-head']
254
310
  db: ['sqlite3']
255
311
  test_targets: ['test_sqlite3']
256
312
 
@@ -260,6 +316,11 @@ jobs:
260
316
 
261
317
  steps:
262
318
  - uses: actions/checkout@v4
319
+ - name: Set up Java 21
320
+ uses: actions/setup-java@v4
321
+ with:
322
+ distribution: 'temurin'
323
+ java-version: '21'
263
324
  - name: Set up Ruby
264
325
  uses: ruby/setup-ruby@v1
265
326
  with:
@@ -271,3 +332,47 @@ jobs:
271
332
  - name: Run tests
272
333
  run: |
273
334
  bundle exec rake ${{ matrix.test_targets }}
335
+
336
+ build-gems:
337
+
338
+ name: Build ActiveRecord-JDBC gems
339
+ runs-on: ubuntu-latest
340
+
341
+ env:
342
+ JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M --dev"
343
+
344
+ steps:
345
+ - uses: actions/checkout@v4
346
+ - name: Set up Java 21
347
+ uses: actions/setup-java@v4
348
+ with:
349
+ distribution: 'temurin'
350
+ java-version: '21'
351
+ - name: Set up Ruby
352
+ uses: ruby/setup-ruby@v1
353
+ with:
354
+ ruby-version: jruby-10.1
355
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
356
+ - name: Build
357
+ run: |
358
+ rake build:adapters
359
+ - name: cache main adapter gem
360
+ uses: actions/upload-artifact@v7
361
+ with:
362
+ path: pkg/activerecord-jdbc-adapter*.gem
363
+ archive: false
364
+ - name: cache sqlite3 adapter gem
365
+ uses: actions/upload-artifact@v7
366
+ with:
367
+ path: pkg/activerecord-jdbcsqlite3-adapter*.gem
368
+ archive: false
369
+ - name: cache mysql adapter gem
370
+ uses: actions/upload-artifact@v7
371
+ with:
372
+ path: pkg/activerecord-jdbcmysql-adapter*.gem
373
+ archive: false
374
+ - name: cache postgresql adapter gem
375
+ uses: actions/upload-artifact@v7
376
+ with:
377
+ path: pkg/activerecord-jdbcpostgresql-adapter*.gem
378
+ archive: false
data/.mise.toml ADDED
@@ -0,0 +1,3 @@
1
+ [tools]
2
+ java = "temurin-21"
3
+ ruby = "jruby-10.0.0.1"
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ # Rails Dependencies Configuration
3
4
  if ENV['RAILS'] # Use local clone of Rails
4
5
  rails_dir = ENV['RAILS']
5
6
  activerecord_dir = ::File.join(rails_dir, 'activerecord')
@@ -41,74 +42,68 @@ elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
41
42
  gem 'actionpack', require: false
42
43
  gem 'actionview', require: false
43
44
  end
44
-
45
45
  end
46
46
  end
47
47
  else
48
48
  if defined? JRUBY_VERSION
49
- gemspec name: 'activerecord-jdbc-adapter' # Use versiom from .gemspec
50
- else # read add_dependency 'activerecord', '~> 7.0' and use the same requirement on MRI
49
+ gemspec name: 'activerecord-jdbc-adapter' # Use version from .gemspec
50
+ else # read add_dependency 'activerecord', '~> 8.0' and use the same requirement on MRI
51
51
  ar_req = File.read('activerecord-jdbc-adapter.gemspec').match(/add_dependency.*?activerecord.*['"](.*?)['"]/)[1]
52
52
  raise "add_dependency 'activerecord', ... line not detected in gemspec" unless ar_req
53
53
  gem 'activerecord', ar_req
54
54
  end
55
55
  end
56
56
 
57
+ # Core Dependencies
57
58
  gem 'rake', require: nil
58
59
 
59
- group :test do
60
- gem 'test-unit', require: nil
61
- gem 'test-unit-context', require: nil
62
- gem 'mocha', '~> 1.2', require: false # Rails has '~> 0.14'
63
-
64
- gem 'bcrypt', '~> 3.1.11', require: false
65
- end
66
-
67
- group :rails do
68
- group :test do
69
- gem 'minitest', '~> 5.24.0', require: nil
70
- gem 'minitest-excludes', require: nil
71
- gem 'minitest-rg', require: nil
72
-
73
- gem 'benchmark-ips', require: nil
74
- end
75
-
76
- # AR expects this for testing xml in postgres (maybe others?)
77
- gem 'builder', require: nil
78
-
79
- gem 'erubis', require: nil # "~> 2.7.0"
80
-
81
- # Due to rails/activesupport/lib/active_support/message_pack.rb
82
- gem 'msgpack', '>= 1.7.0', require: false
83
-
84
- # NOTE: due rails/activerecord/test/cases/connection_management_test.rb
85
- gem 'rack', require: nil
86
-
87
- gem 'zeitwerk'
88
- end
89
-
60
+ # Development Dependencies
90
61
  group :development do
91
- #gem 'ruby-debug', require: nil # if ENV['DEBUG']
62
+ gem 'pry-nav'
63
+
92
64
  group :doc do
93
65
  gem 'yard', require: nil
94
66
  gem 'kramdown', require: nil
95
67
  end
96
68
  end
97
69
 
70
+ # Test Dependencies
98
71
  group :test do
99
- # for testing against different version(s)
100
- if sqlite_version = ENV['JDBC_SQLITE_VERSION']
101
- gem 'jdbc-sqlite3', sqlite_version, require: nil, platform: :jruby
72
+ # Core testing gems
73
+ gem 'test-unit', require: nil
74
+ gem 'test-unit-context', require: nil
75
+ gem 'mocha', '~> 2.0', require: false
76
+ gem 'bcrypt', '~> 3.1', require: false
77
+ gem 'ostruct', require: false
78
+
79
+ # Database adapters for MRI
80
+ platform :mri do
81
+ gem 'mysql2', '~> 0.5', require: nil
82
+ gem 'pg', '~> 1.5', require: nil
83
+ gem 'sqlite3', '~> 2.0', require: nil
102
84
  end
85
+
86
+ # JDBC SQLite version override
87
+ platform :jruby do
88
+ if sqlite_version = ENV['JDBC_SQLITE_VERSION']
89
+ gem 'jdbc-sqlite3', sqlite_version, require: nil
90
+ end
91
+ end
92
+ end
103
93
 
104
- gem 'mysql2', '>= 0.4.4', require: nil, platform: :mri
105
- gem 'pg', '>= 0.18.0', require: nil, platform: :mri
106
- gem 'sqlite3', '~> 1.4', require: nil, platform: :mri
94
+ # Rails-specific test dependencies
95
+ group :rails do
96
+ # Rails testing and support gems
97
+ gem 'builder', require: nil
98
+ gem 'erubis', require: nil
99
+ gem 'msgpack', '~> 1.7', require: false
100
+ gem 'rack', require: nil
101
+ gem 'zeitwerk'
107
102
 
108
- # group :mssql do
109
- # gem 'tiny_tds', require: nil, platform: :mri
110
- # gem 'activerecord-sqlserver-adapter', require: nil, platform: :mri
111
- # end
103
+ group :test do
104
+ gem 'minitest-excludes', require: nil
105
+ gem 'minitest-rg', require: nil
106
+ gem 'minitest-rails', require: nil
107
+ gem 'benchmark-ips', require: nil
108
+ end
112
109
  end
113
-
114
- gem 'pry-nav'
data/README.md CHANGED
@@ -27,9 +27,10 @@ Versions are targeted at certain versions of Rails and live on their own branche
27
27
  | 61.x | 6.1.x | 61-stable | 9.2.7 | 8 |
28
28
  | 70.x | 7.0.x | 70-stable | 9.3.0 | 8 |
29
29
  | 71.x | 7.1.x | 71-stable | 9.4.3 | 8 |
30
- | 72.x | 7.2.x | master | 9.4.3 | 8 |
30
+ | 72.x | 7.2.x | 72-stable | 9.4.3 | 8 |
31
+ | 80.x | 8.0.x | master | 10.0.0 | 21 |
31
32
 
32
- Note: 72.x is still under development and not supported yet.
33
+ Note: 80.x is still under development and not supported yet.
33
34
 
34
35
  Note that JRuby 9.1.x and JRuby 9.2.x are at end-of-life. We recommend Java 8
35
36
  at a minimum for all versions.
data/Rakefile CHANGED
@@ -5,6 +5,21 @@
5
5
  #
6
6
  # Environment variables used by this Rakefile:
7
7
  #
8
+ # DBS
9
+ # Limits the command performed to only work for one of the database
10
+ # types listed in this env var. You can set to a combination of mysql,
11
+ # postgres, or sqlite, separated by commas. For example:
12
+ #
13
+ # mysql,postgres,sqlite
14
+ #
15
+ # You may use pg or postgres as aliases for postgresql
16
+ # You may use sqlite3 as an alias for sqlite
17
+ # You may use all to mean all three
18
+ #
19
+ # NOTE: if you ever want to add a new type of database to be released,
20
+ # just fix up this documentation, the error string in invalid_dbs,
21
+ # and add it to the ALL_DBS array. Everything else should just work!
22
+ #
8
23
  # INCLUDE_JAR_IN_GEM [default task - false, other taks - true]:
9
24
  # Note: This is something you should not normally have to set.
10
25
  # For local development we always will end up including the jar file
@@ -85,6 +100,12 @@ end
85
100
 
86
101
  desc "Releasing AR-JDBC gems (use NOOP=true to disable gem pushing)"
87
102
  task 'release:do' do
103
+ unless ENV["DBS"]
104
+ puts "you must explicitly provide a DBS env var when calling release:do. An empty one will not default to 'all' " \
105
+ "for this command\n\n"
106
+ invalid_dbs!
107
+ end
108
+
88
109
  Rake::Task['build'].invoke
89
110
  Rake::Task['build:adapters'].invoke
90
111
 
@@ -107,8 +128,41 @@ task 'release:push' do
107
128
  sh "for gem in `ls pkg/*-#{current_version.call}-java.gem`; do gem push $gem; done"
108
129
  end
109
130
 
110
- ADAPTERS = %w[mysql postgresql sqlite3].map { |a| "activerecord-jdbc#{a}-adapter" }
111
- DRIVERS = %w[mysql postgres sqlite3].map { |a| "jdbc-#{a}" }
131
+ ALL_DBS = ["mysql", "postgresql", "sqlite3"] #NOTE: if we add a new database type to be released, just add it here!
132
+ DB_ALIASES = ALL_DBS.map {|db| [db, db]}.to_h.merge({
133
+ "pg" => "postgresql",
134
+ "postgres" => "postgresql",
135
+ "sqlite" => "sqlite3"
136
+ })
137
+
138
+ def invalid_dbs!
139
+ raise ArgumentError, "Invalid DBS env var\nThe DBS env var must be set to a combination of mysql, postgres, or " \
140
+ "sqlite, separated by commas. For example:\n\nmysql,postgres,sqlite\n\nYou may use pg or " \
141
+ "postgres as aliases for postgresql\nYou may use sqlite3 as an alias for sqlite\n" \
142
+ "You may use all as a shortcut to listing them all out"
143
+ end
144
+
145
+ def make_db_list
146
+ env_dbs = ENV["DBS"]
147
+ return ALL_DBS if !env_dbs || env_dbs == "all"
148
+ requested = env_dbs.split(",").map(&:strip).reject(&:empty?).map(&:downcase)
149
+ invalid_dbs! unless requested.size > 0 && requested == requested.uniq
150
+
151
+ canonical = requested.map do |name|
152
+ DB_ALIASES.fetch(name) { invalid_dbs! }
153
+ end
154
+
155
+ invalid_dbs! unless canonical == canonical.uniq
156
+
157
+ canonical
158
+ end
159
+
160
+ db_list = make_db_list
161
+ ADAPTERS = db_list.map { |db| "activerecord-jdbc#{db}-adapter" }
162
+
163
+ db_list.map! {|db| db == 'postgresql' ? 'postgres' : db } #naming convention for DRIVERS
164
+ DRIVERS = db_list.map { |a| "jdbc-#{a}" }
165
+
112
166
  TARGETS = ( ADAPTERS + DRIVERS )
113
167
 
114
168
  ADAPTERS.each do |target|
@@ -185,7 +239,7 @@ if defined? JRUBY_VERSION
185
239
  #directory classes = 'pkg/classes'; CLEAN << classes
186
240
 
187
241
  file jar_file => FileList[ 'src/java/**/*.java' ] do
188
- source = target = '1.8'; debug = true
242
+ source = target = '21'; debug = true
189
243
 
190
244
  get_driver_jars_local = lambda do |*args|
191
245
  driver_deps = args.empty? ? [ :Postgres, :MySQL ] : args
@@ -262,18 +316,12 @@ if defined? JRUBY_VERSION
262
316
  end
263
317
 
264
318
  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
267
- 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:'
272
- error "Cannot build activerecord-jdbc with jruby-complete"
273
- end
274
- classpath << File.join(libdir, 'jruby.jar')
319
+ require 'rbconfig'
320
+ libdir = RbConfig::CONFIG['libdir']
321
+ if libdir.start_with? 'classpath:'
322
+ error "Cannot build activerecord-jdbc with jruby-complete"
275
323
  end
276
-
324
+ classpath << File.join(libdir, 'jruby.jar')
277
325
  classpath += driver_jars
278
326
  classpath = classpath.compact.join(File::PATH_SEPARATOR)
279
327
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.homepage = 'https://github.com/jruby/activerecord-jdbc-adapter'
11
11
  gem.license = 'BSD-2-Clause'
12
12
  gem.summary = 'JDBC adapter for ActiveRecord, for use within JRuby on Rails.'
13
- gem.description = "" <<
13
+ gem.description = +"" <<
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, " <<
@@ -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.2.2"
44
+ gem.add_dependency "activerecord", "~> 8.0.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'
@@ -58,7 +58,7 @@ module ArJdbc
58
58
  end
59
59
 
60
60
  # this version of log() automatically fills type_casted_binds from binds if necessary
61
- def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil, async: false)
61
+ def log(sql, name = "SQL", binds = [], type_casted_binds = [], async: false, &block)
62
62
  if binds.any? && (type_casted_binds.nil? || type_casted_binds.empty?)
63
63
  type_casted_binds = lambda {
64
64
  # extract_raw_bind_values
@@ -10,8 +10,6 @@ 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, returning: nil)
13
- sql = transform_query(sql)
14
-
15
13
  if preventing_writes?
16
14
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
17
15
  end
@@ -34,8 +32,6 @@ module ArJdbc
34
32
  # It appears that at this point (AR 5.0) "prepare" should only ever be true
35
33
  # if prepared statements are enabled
36
34
  def internal_exec_query(sql, name = nil, binds = NO_BINDS, prepare: false, async: false, allow_retry: false, materialize_transactions: true)
37
- sql = transform_query(sql)
38
-
39
35
  if preventing_writes? && write_query?(sql)
40
36
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
41
37
  end
@@ -58,8 +54,6 @@ module ArJdbc
58
54
  end
59
55
 
60
56
  def exec_update(sql, name = 'SQL', binds = NO_BINDS)
61
- sql = transform_query(sql)
62
-
63
57
  if preventing_writes?
64
58
  raise ActiveRecord::ReadOnlyError, "Write query attempted while in readonly mode: #{sql}"
65
59
  end
@@ -86,13 +80,23 @@ module ArJdbc
86
80
 
87
81
  private
88
82
 
83
+ def without_prepared_statement?(binds)
84
+ !prepared_statements || binds.empty?
85
+ end
86
+
89
87
  def convert_legacy_binds_to_attributes(binds)
90
88
  binds.map do |column, value|
91
89
  ActiveRecord::Relation::QueryAttribute.new(nil, type_cast(value, column), ActiveModel::Type::Value.new)
92
90
  end
93
91
  end
94
92
 
95
- def raw_execute(sql, name, async: false, allow_retry: false, materialize_transactions: true)
93
+ def preprocess_query(sql)
94
+ check_if_write_query(sql) if respond_to?(:check_if_write_query, true)
95
+ mark_transaction_written_if_write(sql) if respond_to?(:mark_transaction_written_if_write, true)
96
+ sql
97
+ end
98
+
99
+ def raw_execute(sql, name, binds = [], prepare: false, async: false, allow_retry: false, materialize_transactions: true, batch: false)
96
100
  log(sql, name, async: async) do
97
101
  with_raw_connection(allow_retry: allow_retry, materialize_transactions: materialize_transactions) do |conn|
98
102
  result = conn.execute(sql)
Binary file
@@ -219,6 +219,10 @@ module ArJdbc
219
219
  true
220
220
  end
221
221
 
222
+ def supports_native_partitioning?
223
+ database_version >= 100_000
224
+ end
225
+
222
226
  def supports_insert_returning?
223
227
  true
224
228
  end
@@ -953,7 +957,6 @@ module ActiveRecord::ConnectionAdapters
953
957
  FEATURE_NOT_SUPPORTED = "0A000" # :nodoc:
954
958
 
955
959
  def execute_and_clear(sql, name, binds, prepare: false, async: false)
956
- sql = transform_query(sql)
957
960
  check_if_write_query(sql)
958
961
 
959
962
  if !prepare || without_prepared_statement?(binds)