Skip to content

Commit 601219d

Browse files
authored
Merge branch 'master' into jdbc-mysql-8
2 parents f2cde7a + 96317ea commit 601219d

File tree

83 files changed

+787
-2394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+787
-2394
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.tgz
33
*~
44
*.log
5+
/log/
56
patches*
67
*#
78
TAGS
@@ -30,4 +31,4 @@ Gemfile.lock
3031
.idea
3132
.settings
3233
activerecord-jdbc.iml
33-
lib/arjdbc/jdbc/adapter_java.jar
34+
lib/arjdbc/jdbc/adapter_java.jar

.travis.yml

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ dist: xenial
33

44
services:
55
- mysql
6-
addons:
7-
postgresql: 9.4
86

97
before_install:
108
- unset _JAVA_OPTIONS
@@ -17,7 +15,7 @@ install:
1715

1816
language: ruby
1917
rvm:
20-
- jruby-9.2.7.0
18+
- jruby-9.2.9.0
2119
jdk:
2220
- openjdk8
2321

@@ -50,7 +48,7 @@ before_script:
5048
5149
env:
5250
global:
53-
- AR_VERSION="6-0-stable"
51+
- AR_VERSION="master"
5452
matrix:
5553
allow_failures:
5654
- rvm: jruby-head
@@ -60,17 +58,20 @@ matrix:
6058
- env: DB=mysql2 DRIVER=MariaDB
6159

6260
- addons:
63-
postgresql: "9.4"
61+
postgresql: "10"
6462
env: DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=false
6563
- addons:
66-
postgresql: "9.4"
64+
postgresql: "10"
6765
env: DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=true
6866
- addons:
69-
postgresql: "9.4"
67+
postgresql: "10"
7068
env: DB=postgresql PREPARED_STATEMENTS=true
7169
- addons:
72-
postgresql: "9.4"
70+
postgresql: "10"
7371
env: DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
72+
- addons:
73+
postgresql: "9.4"
74+
env: DB=postgresql PREPARED_STATEMENTS=true
7475

7576
- env: DB=sqlite3 PREPARED_STATEMENTS=false
7677
- env: DB=sqlite3 PREPARED_STATEMENTS=true
@@ -84,7 +85,7 @@ matrix:
8485
- env: DB=postgresql
8586
jdk: oraclejdk11
8687
addons:
87-
postgresql: "9.4"
88+
postgresql: "10"
8889
- env: DB=sqlite3
8990
jdk: oraclejdk11
9091

@@ -94,7 +95,7 @@ matrix:
9495
- rvm: jruby-head
9596
env: DB=postgresql
9697
addons:
97-
postgresql: "9.4"
98+
postgresql: "10"
9899
- rvm: jruby-head
99100
env: DB=sqlite3
100101

@@ -107,15 +108,18 @@ matrix:
107108
env: DB=mariadb PREPARED_STATEMENTS=true
108109

109110
# Rails test-suite :
110-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS off by default
111-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" PREPARED_STATEMENTS=true
112-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" DRIVER=MariaDB
111+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="master" # PS off by default
112+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="master" PREPARED_STATEMENTS=true
113+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="master" DRIVER=MariaDB
113114

114115
- addons:
115-
postgresql: "9.4"
116-
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS on by default
116+
postgresql: "10"
117+
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="master" # PS on by default
118+
- addons:
119+
postgresql: "10"
120+
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="master" PREPARED_STATEMENTS=false
117121
- addons:
118122
postgresql: "9.4"
119-
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" PREPARED_STATEMENTS=false
123+
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="master" # PS on by default
120124

121-
- env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="6-0-stable"
125+
- env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="master"

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ end
5959

6060
group :rails do
6161
group :test do
62-
gem 'minitest', '~> 5.11.3', require: nil
62+
gem 'minitest', '~> 5.12.2', require: nil
6363
gem 'minitest-excludes', '~> 2.0.1', require: nil
6464
gem 'minitest-rg', require: nil
6565

README.md

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@
55
ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails'
66
*ActiveRecord* component that can be used with [JRuby][0].
77
ActiveRecord-JDBC-Adapter provides full or nearly full support for:
8-
**MySQL**, **PostgreSQL**, **SQLite3**. In the near future there are plans to
9-
add support **MSSQL**. Unless we get more contributions we will not be going
10-
beyond these four adapters. Note that the amount of work needed to get
11-
another adapter is not huge but the amount of testing required to make sure
12-
that adapter continues to work is not something we can do with the resources
13-
we currently have.
8+
**MySQL**, **PostgreSQL**, **SQLite3** and **MSSQL*** (SQLServer).
149

15-
For Oracle database users you are encouraged to use
16-
https://github.com/rsim/oracle-enhanced.
10+
Unless we get more contributions we will not be supporting more adapters.
11+
Note that the amount of work needed to get another adapter is not huge but
12+
the amount of testing required to make sure that adapter continues to work
13+
is not something we can do with the resources we currently have.
14+
15+
- for **Oracle** database users you are encouraged to use
16+
https://github.com/rsim/oracle-enhanced
17+
- **MSSQL** adapter's gem parts reside in a [separate repository][8]
1718

1819
Versions are targeted at certain versions of Rails and live on their own branches.
1920

20-
| Gem Version | Rails Version | Branch |
21-
| ----------- | ------------- | ------ |
22-
| 50.x | 5.0.x | 50-stable |
23-
| 51.x | 5.1.x | 51-stable |
24-
| 52.x | 5.2.x | 52-stable |
25-
| future | latest | master |
21+
| Gem Version | Rails Version | Branch | min JRuby | min Java |
22+
| ----------- | ------------- | --------- | --------- | -------- |
23+
| 50.x | 5.0.x | 50-stable | 9.1.x | 7 |
24+
| 51.x | 5.1.x | 51-stable | 9.1.x | 7 |
25+
| 52.x | 5.2.x | 52-stable | 9.1.x | 7 |
26+
| 60.x | 6.0.x | 60-stable | 9.2.7 | 8 |
27+
| 61.x | 6.1.x | master | 9.2.7 | 8 |
2628

27-
The minimum version of JRuby for 50+ is JRuby **9.1.x** and
28-
JRuby 9.1+ requires Java 7 or newer (we recommend Java 8 at minimum).
29+
Note that JRuby 9.1.x is end-of-life. We recommend Java 8 at a minimum for all
30+
versions.
2931

3032
## Using ActiveRecord JDBC
3133

@@ -39,6 +41,7 @@ adapters are available:
3941
- MySQL (`activerecord-jdbcmysql-adapter`)
4042
- PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
4143
- SQLite3 (`activerecord-jdbcsqlite3-adapter`)
44+
- MSSQL (`activerecord-jdbcsqlserver-adapter`)
4245

4346
2. If you're generating a new Rails application, use the following command:
4447

@@ -81,6 +84,21 @@ production:
8184
connectTimeout: 60000
8285
```
8386
87+
#### MySQL specific notes
88+
89+
Depending on the MySQL server configuration, it might be required to set
90+
additional connection properties for date/time support to work correctly. If you
91+
encounter problems, try adding this to your database configuration:
92+
93+
```yml
94+
properties:
95+
serverTimezone: <%= java.util.TimeZone.getDefault.getID %>
96+
```
97+
98+
The correct timezone depends on the system setup, but the one shown is a good
99+
place to start and is actually the correct setting for many systems.
100+
101+
84102
### Standalone with ActiveRecord
85103
86104
Once the setup is made (see below) you can establish a JDBC connection like this
@@ -155,7 +173,8 @@ ask on the #JRuby IRC channel on http://freenode.net/ (try [web-chat][6]).
155173
This project was originally written by [Nick Sieger](http://github.com/nicksieger)
156174
and [Ola Bini](http://github.com/olabini) with lots of help from the JRuby community.
157175
Polished 3.x compatibility and 4.x support (for AR-JDBC >= 1.3.0) was managed by
158-
[Karol Bucek](http://github.com/kares) among others.
176+
[Karol Bucek](http://github.com/kares) among others. Support for Rails 6 was
177+
contributed by [shellyBits GmbH](https://shellybits.ch/)
159178

160179
## License
161180

@@ -173,4 +192,4 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
173192
[5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
174193
[6]: https://webchat.freenode.net/?channels=#jruby
175194
[7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
176-
[8]: https://github.com/jruby/activerecord-jdbc-adapter/wiki/Migrating-from-1.2.x-to-1.3.0
195+
[8]: https://github.com/jruby/activerecord-jdbcsqlserver-adapter

Rakefile

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
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+
127
require 'rake/clean'
228

329
CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
@@ -38,7 +64,8 @@ rake = lambda { |task| ruby "-S", "rake", task }
3864

3965
desc "Build #{gem_name} gem into the pkg directory."
4066
task :build => :jar do
41-
sh("RELEASE=#{ENV['RELEASE']} gem build -V '#{gemspec_path}'") do
67+
include_jar = ENV['INCLUDE_JAR_IN_GEM'] || 'true'
68+
sh("INCLUDE_JAR_IN_GEM=#{include_jar} gem build -V '#{gemspec_path}'") do
4269
gem_path = built_gem_path.call
4370
file_name = File.basename(gem_path)
4471
FileUtils.mkdir_p(File.join(base_dir, 'pkg'))
@@ -58,7 +85,6 @@ end
5885

5986
desc "Releasing AR-JDBC gems (use NOOP=true to disable gem pushing)"
6087
task 'release:do' do
61-
ENV['RELEASE'] = 'true' # so that .gemspec is built with adapter_java.jar
6288
Rake::Task['build'].invoke
6389
Rake::Task['build:adapters'].invoke
6490

@@ -257,7 +283,7 @@ if defined? JRUBY_VERSION
257283
begin
258284
require 'arjdbc/version'
259285
rescue LoadError
260-
path = File.expand_path('../lib', File.dirname(__FILE__))
286+
path = File.expand_path('lib', File.dirname(__FILE__))
261287
unless $LOAD_PATH.include?(path)
262288
$LOAD_PATH << path; retry
263289
end
@@ -297,7 +323,7 @@ if defined? JRUBY_VERSION
297323
# class_files.gsub!('$', '\$') unless windows?
298324
# args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
299325

300-
if ENV['RELEASE'] == 'true'; require 'tempfile'
326+
if ENV['INCLUDE_JAR_IN_GEM'] == 'true'; require 'tempfile'
301327
manifest = "Built-Time: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')}\n"
302328
manifest += "Built-JRuby: #{JRUBY_VERSION}\n"
303329
manifest += "Specification-Title: ActiveRecord-JDBC\n"

activerecord-jdbc-adapter.gemspec

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ Gem::Specification.new do |gem|
1111
gem.license = 'BSD-2-Clause'
1212
gem.summary = 'JDBC adapter for ActiveRecord, for use within JRuby on Rails.'
1313
gem.description = "" <<
14-
"AR-JDBC is a database adapter for Rails' ActiveRecord component designed " <<
15-
"to be used with JRuby built upon Java's JDBC API for database access. " <<
16-
"Provides (ActiveRecord) built-in adapters: MySQL, PostgreSQL and SQLite3 " <<
17-
"as well as adapters for popular databases such as Oracle, SQLServer, " <<
18-
"DB2, FireBird and even Java (embed) databases: Derby, HSQLDB and H2. " <<
19-
"It allows to connect to virtually any JDBC-compliant database with your " <<
20-
"JRuby on Rails application."
14+
"AR-JDBC is a database adapter for Rails' ActiveRecord component " <<
15+
"designed to be used with JRuby built upon Java's JDBC API for " <<
16+
"database access. Provides (ActiveRecord) built-in adapters: MySQL, " <<
17+
"PostgreSQL, SQLite3, and SQLServer."
2118

2219
gem.require_paths = ["lib"]
2320

@@ -27,7 +24,7 @@ Gem::Specification.new do |gem|
2724
reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
2825
gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
2926

30-
if ENV['RELEASE'] != 'true' # @see Rakefile
27+
if ENV['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
3128
gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
3229

3330
#gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
@@ -44,7 +41,7 @@ Gem::Specification.new do |gem|
4441
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
4542
gem.test_files = gem.files.grep(%r{^test/})
4643

47-
gem.add_dependency 'activerecord', '~> 6.0.0.rc1'
44+
gem.add_dependency 'activerecord', '~> 6.0.0'
4845

4946
#gem.add_development_dependency 'test-unit', '2.5.4'
5047
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'

bench/setup.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,22 @@
22

33
require 'rubygems' unless defined? Gem
44

5-
gem 'activerecord', ENV['AR_VERSION'] if ENV['AR_VERSION']
5+
if ENV['RAILS'] # Use local clone of Rails
6+
rails_dir = ENV['RAILS']
7+
8+
activerecord_dir = ::File.join(rails_dir, 'activerecord', 'lib')
9+
if !::File.exist?(rails_dir) && !::File.exist?(activerecord_dir)
10+
raise "ENV['RAILS'] set but does not point at a valid rails clone"
11+
end
12+
puts "--- Using AR from #{activerecord_dir}"
13+
14+
$LOAD_PATH << ::File.join(rails_dir, 'activesupport', 'lib')
15+
$LOAD_PATH << ::File.join(rails_dir, 'activemodel', 'lib')
16+
$LOAD_PATH << activerecord_dir
17+
elsif ENV['AR_VERSION']
18+
gem 'activerecord', ENV['AR_VERSION']
19+
end
20+
621
require 'active_record'
722
require 'active_record/version'
823

@@ -12,7 +27,7 @@
1227
require 'arjdbc'
1328
ArJdbc::VERSION
1429
else
15-
$LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
30+
$LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
1631
require 'arjdbc'
1732
"#{ArJdbc::VERSION} #{`git rev-parse HEAD`[0, 8]}"
1833
end

lib/active_record/connection_adapters/mssql_adapter.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

lib/arjdbc/abstract/core.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def translate_exception(exception, message:, sql:, binds:)
5656
case exception
5757
when SystemExit, SignalException, NoMemoryError then exception
5858
when ActiveModel::RangeError, TypeError, RuntimeError then exception
59-
else ActiveRecord::StatementInvalid.new(message, sql: sql, binds: binds)
59+
else super
6060
end
6161
end
6262

0 commit comments

Comments
 (0)