activerecord-jdbc-alt-adapter 52.6.0-java → 60.0.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/.travis.yml +58 -37
- data/Gemfile +9 -2
- data/README.md +30 -14
- data/Rakefile +1 -1
- data/Rakefile.jdbc +8 -1
- data/activerecord-jdbc-adapter.gemspec +5 -8
- data/activerecord-jdbc-alt-adapter.gemspec +5 -8
- data/lib/arel/visitors/sqlserver.rb +33 -23
- data/lib/arjdbc/abstract/connection_management.rb +7 -0
- data/lib/arjdbc/abstract/core.rb +16 -23
- data/lib/arjdbc/abstract/database_statements.rb +24 -0
- data/lib/arjdbc/abstract/statement_cache.rb +2 -5
- data/lib/arjdbc/abstract/transaction_support.rb +5 -3
- data/lib/arjdbc/db2/column.rb +0 -39
- data/lib/arjdbc/derby/adapter.rb +1 -20
- data/lib/arjdbc/firebird/adapter.rb +0 -21
- data/lib/arjdbc/h2/adapter.rb +0 -15
- data/lib/arjdbc/hsqldb/adapter.rb +0 -14
- data/lib/arjdbc/informix/adapter.rb +0 -23
- data/lib/arjdbc/jdbc/adapter.rb +3 -1
- data/lib/arjdbc/jdbc/adapter_require.rb +3 -1
- data/lib/arjdbc/jdbc/base_ext.rb +3 -1
- data/lib/arjdbc/jdbc/callbacks.rb +2 -0
- data/lib/arjdbc/jdbc/column.rb +2 -0
- data/lib/arjdbc/jdbc/connection.rb +2 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +2 -0
- data/lib/arjdbc/jdbc/error.rb +2 -0
- data/lib/arjdbc/jdbc/extension.rb +2 -0
- data/lib/arjdbc/jdbc/java.rb +3 -1
- data/lib/arjdbc/jdbc/railtie.rb +3 -1
- data/lib/arjdbc/jdbc/rake_tasks.rb +3 -1
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -1
- data/lib/arjdbc/jdbc/type_cast.rb +2 -0
- data/lib/arjdbc/jdbc/type_converter.rb +2 -0
- data/lib/arjdbc/mssql.rb +3 -1
- data/lib/arjdbc/mssql/adapter.rb +105 -36
- data/lib/arjdbc/mssql/column.rb +5 -1
- data/lib/arjdbc/mssql/connection_methods.rb +8 -2
- data/lib/arjdbc/mssql/database_limits.rb +2 -0
- data/lib/arjdbc/mssql/database_statements.rb +43 -5
- data/lib/arjdbc/mssql/errors.rb +2 -0
- data/lib/arjdbc/mssql/explain_support.rb +3 -1
- data/lib/arjdbc/mssql/extensions/attribute_methods.rb +5 -1
- data/lib/arjdbc/mssql/extensions/calculations.rb +2 -0
- data/lib/arjdbc/mssql/quoting.rb +38 -0
- data/lib/arjdbc/mssql/schema_creation.rb +24 -2
- data/lib/arjdbc/mssql/schema_definitions.rb +10 -0
- data/lib/arjdbc/mssql/schema_dumper.rb +2 -0
- data/lib/arjdbc/mssql/schema_statements.rb +63 -21
- data/lib/arjdbc/mssql/transaction.rb +2 -0
- data/lib/arjdbc/mssql/types.rb +2 -0
- data/lib/arjdbc/mssql/types/binary_types.rb +2 -0
- data/lib/arjdbc/mssql/types/date_and_time_types.rb +2 -0
- data/lib/arjdbc/mssql/types/deprecated_types.rb +2 -0
- data/lib/arjdbc/mssql/types/numeric_types.rb +2 -0
- data/lib/arjdbc/mssql/types/string_types.rb +2 -0
- data/lib/arjdbc/mssql/utils.rb +2 -0
- data/lib/arjdbc/mysql/adapter.rb +47 -18
- data/lib/arjdbc/postgresql/adapter.rb +220 -213
- data/lib/arjdbc/postgresql/base/array_decoder.rb +2 -0
- data/lib/arjdbc/postgresql/base/array_encoder.rb +4 -2
- data/lib/arjdbc/postgresql/base/array_parser.rb +4 -2
- data/lib/arjdbc/postgresql/base/pgconn.rb +2 -0
- data/lib/arjdbc/postgresql/column.rb +6 -4
- data/lib/arjdbc/postgresql/name.rb +2 -0
- data/lib/arjdbc/postgresql/oid_types.rb +2 -0
- data/lib/arjdbc/sqlite3/adapter.rb +175 -180
- data/lib/arjdbc/sqlite3/connection_methods.rb +15 -4
- data/lib/arjdbc/tasks/databases.rake +13 -10
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +49 -5
- data/lib/arjdbc/util/quoted_cache.rb +3 -1
- data/lib/arjdbc/util/serialized_attributes.rb +3 -1
- data/lib/arjdbc/util/table_copier.rb +3 -1
- data/lib/arjdbc/version.rb +1 -1
- data/pom.xml +4 -4
- data/rakelib/01-tomcat.rake +2 -2
- data/src/java/arjdbc/ArJdbcModule.java +5 -5
- data/src/java/arjdbc/jdbc/DriverWrapper.java +1 -9
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +406 -629
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +37 -51
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +13 -23
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +31 -24
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +94 -99
- data/src/java/arjdbc/util/DateTimeUtils.java +12 -4
- metadata +8 -16
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4018232c43fd8cfccb8349f8c9a1be1ebd8addf9aaa8f96f3830df20ceb33c96
|
|
4
|
+
data.tar.gz: 0a4971a64e52dbd5e3623777593d596511d96da7217ef8bcc83472a7638fd9d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28bae6826777ff61c6643bb96fab4aba5489c6d6650d6d1cfa1f3773f5cf7f85464b96e58ec113d61a02b513e928dcf71d82c63b569b710c247bd15ef371bb41
|
|
7
|
+
data.tar.gz: 733b05c9b0ccb42aa53480f8a4ee4bd6432849defb4483f3583364120420bf1c90df011a5b7abf73bb83c55cc3b85e71bb863da7cbc025852862ccc85841daf0
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -3,8 +3,6 @@ dist: xenial
|
|
|
3
3
|
|
|
4
4
|
services:
|
|
5
5
|
- mysql
|
|
6
|
-
addons:
|
|
7
|
-
postgresql: 9.4
|
|
8
6
|
|
|
9
7
|
before_install:
|
|
10
8
|
- unset _JAVA_OPTIONS
|
|
@@ -17,7 +15,7 @@ install:
|
|
|
17
15
|
|
|
18
16
|
language: ruby
|
|
19
17
|
rvm:
|
|
20
|
-
- jruby-9.
|
|
18
|
+
- jruby-9.2.7.0
|
|
21
19
|
jdk:
|
|
22
20
|
- openjdk8
|
|
23
21
|
|
|
@@ -49,45 +47,58 @@ before_script:
|
|
|
49
47
|
|| true
|
|
50
48
|
|
|
51
49
|
env:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- DB=mysql2 DRIVER=MariaDB
|
|
55
|
-
- DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=false
|
|
56
|
-
- DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=true
|
|
57
|
-
- DB=postgresql PREPARED_STATEMENTS=true
|
|
58
|
-
- DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
|
|
59
|
-
- DB=sqlite3 PREPARED_STATEMENTS=false
|
|
60
|
-
- DB=sqlite3 PREPARED_STATEMENTS=true
|
|
61
|
-
- DB=jndi PREPARED_STATEMENTS=false
|
|
62
|
-
- DB=jndi PREPARED_STATEMENTS=true
|
|
50
|
+
global:
|
|
51
|
+
- AR_VERSION="6-0-stable"
|
|
63
52
|
matrix:
|
|
64
53
|
allow_failures:
|
|
65
54
|
- rvm: jruby-head
|
|
66
55
|
include:
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
env: DB=
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
env: DB=
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
env: DB=postgresql
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
env: DB=
|
|
83
|
-
|
|
56
|
+
- env: DB=mysql2 PREPARED_STATEMENTS=false
|
|
57
|
+
- env: DB=mysql2 PREPARED_STATEMENTS=true
|
|
58
|
+
- env: DB=mysql2 DRIVER=MariaDB
|
|
59
|
+
|
|
60
|
+
- addons:
|
|
61
|
+
postgresql: "10"
|
|
62
|
+
env: DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=false
|
|
63
|
+
- addons:
|
|
64
|
+
postgresql: "10"
|
|
65
|
+
env: DB=postgresql PREPARED_STATEMENTS=false INSERT_RETURNING=true
|
|
66
|
+
- addons:
|
|
67
|
+
postgresql: "10"
|
|
68
|
+
env: DB=postgresql PREPARED_STATEMENTS=true
|
|
69
|
+
- addons:
|
|
70
|
+
postgresql: "10"
|
|
71
|
+
env: DB=postgresql PREPARED_STATEMENTS=true INSERT_RETURNING=true
|
|
72
|
+
- addons:
|
|
73
|
+
postgresql: "9.4"
|
|
74
|
+
env: DB=postgresql PREPARED_STATEMENTS=true
|
|
75
|
+
|
|
76
|
+
- env: DB=sqlite3 PREPARED_STATEMENTS=false
|
|
77
|
+
- env: DB=sqlite3 PREPARED_STATEMENTS=true
|
|
78
|
+
|
|
79
|
+
- env: DB=jndi PREPARED_STATEMENTS=false
|
|
80
|
+
- env: DB=jndi PREPARED_STATEMENTS=true
|
|
81
|
+
|
|
82
|
+
# Java 11
|
|
83
|
+
- env: DB=mysql2
|
|
84
|
+
jdk: oraclejdk11
|
|
85
|
+
- env: DB=postgresql
|
|
86
|
+
jdk: oraclejdk11
|
|
87
|
+
addons:
|
|
88
|
+
postgresql: "10"
|
|
89
|
+
- env: DB=sqlite3
|
|
90
|
+
jdk: oraclejdk11
|
|
91
|
+
|
|
84
92
|
# jruby-head
|
|
85
93
|
- rvm: jruby-head
|
|
86
94
|
env: DB=mysql2
|
|
87
95
|
- rvm: jruby-head
|
|
88
96
|
env: DB=postgresql
|
|
97
|
+
addons:
|
|
98
|
+
postgresql: "10"
|
|
89
99
|
- rvm: jruby-head
|
|
90
100
|
env: DB=sqlite3
|
|
101
|
+
|
|
91
102
|
# testing against MariaDB
|
|
92
103
|
- addons:
|
|
93
104
|
mariadb: 10.2
|
|
@@ -95,10 +106,20 @@ matrix:
|
|
|
95
106
|
- addons:
|
|
96
107
|
mariadb: 10.3
|
|
97
108
|
env: DB=mariadb PREPARED_STATEMENTS=true
|
|
109
|
+
|
|
98
110
|
# Rails test-suite :
|
|
99
|
-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="
|
|
100
|
-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="
|
|
101
|
-
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="
|
|
102
|
-
|
|
103
|
-
-
|
|
104
|
-
|
|
111
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS off by default
|
|
112
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" PREPARED_STATEMENTS=true
|
|
113
|
+
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="6-0-stable" DRIVER=MariaDB
|
|
114
|
+
|
|
115
|
+
- addons:
|
|
116
|
+
postgresql: "10"
|
|
117
|
+
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS on by default
|
|
118
|
+
- addons:
|
|
119
|
+
postgresql: "10"
|
|
120
|
+
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" PREPARED_STATEMENTS=false
|
|
121
|
+
- addons:
|
|
122
|
+
postgresql: "9.4"
|
|
123
|
+
env: DB=postgresql TEST_PREFIX="rails:" AR_VERSION="6-0-stable" # PS on by default
|
|
124
|
+
|
|
125
|
+
- env: DB=sqlite3 TEST_PREFIX="rails:" AR_VERSION="6-0-stable"
|
data/Gemfile
CHANGED
|
@@ -10,10 +10,15 @@ if ENV['RAILS'] # Use local clone of Rails
|
|
|
10
10
|
|
|
11
11
|
activemodel_dir = ::File.join(rails_dir, 'activemodel')
|
|
12
12
|
activesupport_dir = ::File.join(rails_dir, 'activesupport')
|
|
13
|
-
|
|
13
|
+
actionpack_dir = ::File.join(rails_dir, 'actionpack')
|
|
14
|
+
actionview_dir = ::File.join(rails_dir, 'actionview')
|
|
15
|
+
|
|
14
16
|
gem 'activerecord', require: false, path: activerecord_dir
|
|
15
17
|
gem 'activemodel', require: false, path: activemodel_dir
|
|
16
18
|
gem 'activesupport', require: false, path: activesupport_dir
|
|
19
|
+
gem 'actionpack', require: false, path: actionpack_dir
|
|
20
|
+
gem 'actionview', require: false, path: actionview_dir
|
|
21
|
+
|
|
17
22
|
elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
|
|
18
23
|
version = ENV['AR_VERSION']
|
|
19
24
|
|
|
@@ -28,11 +33,13 @@ elsif ENV['AR_VERSION'] # Use specific version of AR and not .gemspec version
|
|
|
28
33
|
else # branch
|
|
29
34
|
opts = {branch: version}
|
|
30
35
|
end
|
|
31
|
-
|
|
36
|
+
|
|
32
37
|
git 'https://github.com/rails/rails.git', **opts do
|
|
33
38
|
gem 'activerecord', require: false
|
|
34
39
|
gem 'activemodel', require: false
|
|
35
40
|
gem 'activesupport', require: false
|
|
41
|
+
gem 'actionpack', require: false
|
|
42
|
+
gem 'actionview', require: false
|
|
36
43
|
end
|
|
37
44
|
end
|
|
38
45
|
end
|
data/README.md
CHANGED
|
@@ -8,9 +8,9 @@ use the [original adapter](https://github.com/jruby/active)
|
|
|
8
8
|
This adapter only works with JRuby and it is advised to install the latest
|
|
9
9
|
stable versions of Rails
|
|
10
10
|
|
|
11
|
-
- For Rails `5.0.7` install the `50.
|
|
12
|
-
- For Rails `5.1.7` install the `51.
|
|
13
|
-
- For Rails `5.2.
|
|
11
|
+
- For Rails `5.0.7.2` install the `50.3.1` version of this adapter
|
|
12
|
+
- For Rails `5.1.7` install the `51.3.0` version of this adapter
|
|
13
|
+
- For Rails `5.2.3` install the `52.2.0` version of this adapter
|
|
14
14
|
|
|
15
15
|
Support for Rails 6.0 is planned in the future.
|
|
16
16
|
|
|
@@ -24,8 +24,8 @@ Add the following to your `Gemfile`:
|
|
|
24
24
|
```ruby
|
|
25
25
|
platforms :jruby do
|
|
26
26
|
# Use jdbc as the database for Active Record
|
|
27
|
-
gem 'activerecord-jdbc-alt-adapter', '~>
|
|
28
|
-
gem 'jdbc-mssql', '~> 0.
|
|
27
|
+
gem 'activerecord-jdbc-alt-adapter', '~> 50.3.1', require: 'arjdbc'
|
|
28
|
+
gem 'jdbc-mssql', '~> 0.6.0'
|
|
29
29
|
end
|
|
30
30
|
```
|
|
31
31
|
|
|
@@ -130,15 +130,15 @@ is not something we can do with the resources we currently have.
|
|
|
130
130
|
|
|
131
131
|
Versions are targeted at certain versions of Rails and live on their own branches.
|
|
132
132
|
|
|
133
|
-
| Gem Version | Rails Version | Branch |
|
|
134
|
-
| ----------- | ------------- |
|
|
135
|
-
| 50.x | 5.0.x | 50-stable |
|
|
136
|
-
| 51.x | 5.1.x | 51-stable |
|
|
137
|
-
| 52.x | 5.2.x | 52-stable |
|
|
138
|
-
|
|
|
133
|
+
| Gem Version | Rails Version | Branch | min JRuby | min Java |
|
|
134
|
+
| ----------- | ------------- | --------- | --------- | -------- |
|
|
135
|
+
| 50.x | 5.0.x | 50-stable | 9.1.x | 7 |
|
|
136
|
+
| 51.x | 5.1.x | 51-stable | 9.1.x | 7 |
|
|
137
|
+
| 52.x | 5.2.x | 52-stable | 9.1.x | 7 |
|
|
138
|
+
| 60.x | 6.0.x | master | 9.2.7 | 8 |
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
Note that JRuby 9.1.x is end-of-life. We recommend Java 8 at a minimum for all
|
|
141
|
+
versions.
|
|
142
142
|
|
|
143
143
|
## Using ActiveRecord JDBC
|
|
144
144
|
|
|
@@ -195,6 +195,21 @@ production:
|
|
|
195
195
|
connectTimeout: 60000
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
+
#### MySQL specific notes
|
|
199
|
+
|
|
200
|
+
Depending on the MySQL server configuration, it might be required to set
|
|
201
|
+
additional connection properties for date/time support to work correctly. If you
|
|
202
|
+
encounter problems, try adding this to your database configuration:
|
|
203
|
+
|
|
204
|
+
```yml
|
|
205
|
+
properties:
|
|
206
|
+
serverTimezone: <%= java.util.TimeZone.getDefault.getID %>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
The correct timezone depends on the system setup, but the one shown is a good
|
|
210
|
+
place to start and is actually the correct setting for many systems.
|
|
211
|
+
|
|
212
|
+
|
|
198
213
|
### Standalone with ActiveRecord
|
|
199
214
|
|
|
200
215
|
Once the setup is made (see below) you can establish a JDBC connection like this
|
|
@@ -269,7 +284,8 @@ ask on the #JRuby IRC channel on http://freenode.net/ (try [web-chat][6]).
|
|
|
269
284
|
This project was originally written by [Nick Sieger](http://github.com/nicksieger)
|
|
270
285
|
and [Ola Bini](http://github.com/olabini) with lots of help from the JRuby community.
|
|
271
286
|
Polished 3.x compatibility and 4.x support (for AR-JDBC >= 1.3.0) was managed by
|
|
272
|
-
[Karol Bucek](http://github.com/kares) among others.
|
|
287
|
+
[Karol Bucek](http://github.com/kares) among others. Support for Rails 6 was
|
|
288
|
+
contributed by [shellyBits GmbH](https://shellybits.ch/)
|
|
273
289
|
|
|
274
290
|
## License
|
|
275
291
|
|
data/Rakefile
CHANGED
|
@@ -185,7 +185,7 @@ if defined? JRUBY_VERSION
|
|
|
185
185
|
#directory classes = 'pkg/classes'; CLEAN << classes
|
|
186
186
|
|
|
187
187
|
file jar_file => FileList[ 'src/java/**/*.java' ] do
|
|
188
|
-
source = target = '1.
|
|
188
|
+
source = target = '1.8'; debug = true
|
|
189
189
|
|
|
190
190
|
get_driver_jars_local = lambda do |*args|
|
|
191
191
|
driver_deps = args.empty? ? [ :Postgres, :MySQL ] : args
|
data/Rakefile.jdbc
CHANGED
|
@@ -17,4 +17,11 @@ desc "Build and install #{name}-#{version} gem into system gems"
|
|
|
17
17
|
task('install') { gem_helper.install_gem }
|
|
18
18
|
|
|
19
19
|
desc "Create tag #{version_tag} build and push #{name}-#{version} gem to Rubygems"
|
|
20
|
-
task('release')
|
|
20
|
+
task('release') do
|
|
21
|
+
gem_helper.instance_eval do
|
|
22
|
+
guard_clean
|
|
23
|
+
built_gem_path = build_gem
|
|
24
|
+
tag_version unless already_tagged?
|
|
25
|
+
rubygem_push(built_gem_path) if gem_push?
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -11,13 +11,10 @@ Gem::Specification.new do |gem|
|
|
|
11
11
|
gem.license = 'BSD-2-Clause'
|
|
12
12
|
gem.summary = 'JDBC adapter for ActiveRecord, for use within JRuby on Rails.'
|
|
13
13
|
gem.description = "" <<
|
|
14
|
-
"AR-JDBC is a database adapter for Rails' ActiveRecord component
|
|
15
|
-
"to be used with JRuby built upon Java's JDBC API for
|
|
16
|
-
"Provides (ActiveRecord) built-in adapters: MySQL,
|
|
17
|
-
"
|
|
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."
|
|
21
18
|
|
|
22
19
|
gem.require_paths = ["lib"]
|
|
23
20
|
|
|
@@ -44,7 +41,7 @@ Gem::Specification.new do |gem|
|
|
|
44
41
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
45
42
|
gem.test_files = gem.files.grep(%r{^test/})
|
|
46
43
|
|
|
47
|
-
gem.add_dependency 'activerecord', '~>
|
|
44
|
+
gem.add_dependency 'activerecord', '~> 6.0.0'
|
|
48
45
|
|
|
49
46
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
|
50
47
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
|
@@ -13,13 +13,10 @@ Gem::Specification.new do |gem|
|
|
|
13
13
|
gem.description = "" <<
|
|
14
14
|
"Fork of the ActiveRecord JDBC adapter with support for SQL Server and Azure SQL, " <<
|
|
15
15
|
"for more information and help look at the README file in the github repository. " <<
|
|
16
|
-
"AR-JDBC is a database adapter for Rails' ActiveRecord component
|
|
17
|
-
"to be used with JRuby built upon Java's JDBC API for
|
|
18
|
-
"Provides (ActiveRecord) built-in adapters: MySQL,
|
|
19
|
-
"
|
|
20
|
-
"DB2, FireBird and even Java (embed) databases: Derby, HSQLDB and H2. " <<
|
|
21
|
-
"It allows to connect to virtually any JDBC-compliant database with your " <<
|
|
22
|
-
"JRuby on Rails application."
|
|
16
|
+
"AR-JDBC is a database adapter for Rails' ActiveRecord component " <<
|
|
17
|
+
"designed to be used with JRuby built upon Java's JDBC API for " <<
|
|
18
|
+
"database access. Provides (ActiveRecord) built-in adapters: MySQL, " <<
|
|
19
|
+
"PostgreSQL, SQLite3, and SQLServer."
|
|
23
20
|
|
|
24
21
|
gem.require_paths = ["lib"]
|
|
25
22
|
|
|
@@ -46,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
|
46
43
|
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
47
44
|
gem.test_files = gem.files.grep(%r{^test/})
|
|
48
45
|
|
|
49
|
-
gem.add_dependency 'activerecord', '~>
|
|
46
|
+
gem.add_dependency 'activerecord', '~> 6.0.0'
|
|
50
47
|
|
|
51
48
|
#gem.add_development_dependency 'test-unit', '2.5.4'
|
|
52
49
|
#gem.add_development_dependency 'test-unit-context', '>= 0.3.0'
|
|
@@ -4,13 +4,8 @@
|
|
|
4
4
|
module Arel
|
|
5
5
|
module Visitors
|
|
6
6
|
class SQLServer < Arel::Visitors::ToSql
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
ROWS = " ROWS"
|
|
10
|
-
FETCH = " FETCH NEXT "
|
|
11
|
-
FETCH0 = " FETCH FIRST (SELECT 0) "
|
|
12
|
-
ROWS_ONLY = " ROWS ONLY"
|
|
13
|
-
|
|
7
|
+
# 'FETCH FIRST' or 'FETCH NEXT' do the same thing
|
|
8
|
+
# The SQL ANSI Standard says NEXT and FIRST are synonyms
|
|
14
9
|
|
|
15
10
|
private
|
|
16
11
|
|
|
@@ -35,24 +30,24 @@ module Arel
|
|
|
35
30
|
|
|
36
31
|
def visit_Arel_Nodes_Lock o, collector
|
|
37
32
|
o.expr = Arel.sql('WITH(UPDLOCK)') if o.expr.to_s =~ /FOR UPDATE/
|
|
38
|
-
collector <<
|
|
33
|
+
collector << ' '
|
|
39
34
|
visit o.expr, collector
|
|
40
35
|
end
|
|
41
36
|
|
|
42
37
|
def visit_Arel_Nodes_Offset o, collector
|
|
43
|
-
collector << OFFSET
|
|
38
|
+
collector << ' OFFSET '
|
|
44
39
|
visit o.expr, collector
|
|
45
|
-
collector << ROWS
|
|
40
|
+
collector << ' ROWS'
|
|
46
41
|
end
|
|
47
42
|
|
|
48
43
|
def visit_Arel_Nodes_Limit o, collector
|
|
49
44
|
if node_value(o) == 0
|
|
50
|
-
collector <<
|
|
51
|
-
collector <<
|
|
45
|
+
collector << ' FETCH FIRST (SELECT 0) '
|
|
46
|
+
collector << ' ROWS ONLY'
|
|
52
47
|
else
|
|
53
|
-
collector << FETCH
|
|
48
|
+
collector << ' FETCH NEXT '
|
|
54
49
|
visit o.expr, collector
|
|
55
|
-
collector <<
|
|
50
|
+
collector << ' ROWS ONLY'
|
|
56
51
|
end
|
|
57
52
|
end
|
|
58
53
|
|
|
@@ -61,7 +56,7 @@ module Arel
|
|
|
61
56
|
distinct_One_As_One_Is_So_Not_Fetch o
|
|
62
57
|
if o.with
|
|
63
58
|
collector = visit o.with, collector
|
|
64
|
-
collector <<
|
|
59
|
+
collector << ' '
|
|
65
60
|
end
|
|
66
61
|
collector = o.cores.inject(collector) { |c,x|
|
|
67
62
|
visit_Arel_Nodes_SelectCore(x, c)
|
|
@@ -99,7 +94,7 @@ module Arel
|
|
|
99
94
|
collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector
|
|
100
95
|
end
|
|
101
96
|
if o.right.any?
|
|
102
|
-
collector <<
|
|
97
|
+
collector << ' ' if o.left
|
|
103
98
|
collector = inject_join o.right, collector, ' '
|
|
104
99
|
end
|
|
105
100
|
collector
|
|
@@ -110,7 +105,7 @@ module Arel
|
|
|
110
105
|
collector = visit o.left, collector
|
|
111
106
|
collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, space: true
|
|
112
107
|
if o.right
|
|
113
|
-
collector <<
|
|
108
|
+
collector << ' '
|
|
114
109
|
visit(o.right, collector)
|
|
115
110
|
else
|
|
116
111
|
collector
|
|
@@ -121,16 +116,31 @@ module Arel
|
|
|
121
116
|
collector << "LEFT OUTER JOIN "
|
|
122
117
|
collector = visit o.left, collector
|
|
123
118
|
collector = visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, space: true
|
|
124
|
-
collector <<
|
|
119
|
+
collector << ' '
|
|
125
120
|
visit o.right, collector
|
|
126
121
|
end
|
|
127
122
|
|
|
123
|
+
# NOTE: this overrides the original method in arel visitors 'to_sql.rb'
|
|
124
|
+
# fixes The ORDER BY clause is invalid in subqueries
|
|
125
|
+
# FIXME: we should probably have a 2-pass visitor for this
|
|
126
|
+
def build_subselect(key, o)
|
|
127
|
+
stmt = Nodes::SelectStatement.new
|
|
128
|
+
core = stmt.cores.first
|
|
129
|
+
core.froms = o.relation
|
|
130
|
+
core.wheres = o.wheres
|
|
131
|
+
core.projections = [key]
|
|
132
|
+
stmt.limit = o.limit
|
|
133
|
+
stmt.offset = o.offset
|
|
134
|
+
stmt.orders = []
|
|
135
|
+
stmt
|
|
136
|
+
end
|
|
137
|
+
|
|
128
138
|
# SQLServer ToSql/Visitor (Additions)
|
|
129
139
|
|
|
130
140
|
def visit_Arel_Nodes_SelectStatement_SQLServer_Lock collector, options = {}
|
|
131
141
|
if select_statement_lock?
|
|
132
142
|
collector = visit @select_statement.lock, collector
|
|
133
|
-
collector <<
|
|
143
|
+
collector << ' ' if options[:space]
|
|
134
144
|
end
|
|
135
145
|
collector
|
|
136
146
|
end
|
|
@@ -138,12 +148,12 @@ module Arel
|
|
|
138
148
|
def visit_Orders_And_Let_Fetch_Happen o, collector
|
|
139
149
|
make_Fetch_Possible_And_Deterministic o
|
|
140
150
|
unless o.orders.empty?
|
|
141
|
-
collector <<
|
|
142
|
-
collector <<
|
|
151
|
+
collector << ' '
|
|
152
|
+
collector << ' ORDER BY '
|
|
143
153
|
len = o.orders.length - 1
|
|
144
154
|
o.orders.each_with_index { |x, i|
|
|
145
155
|
collector = visit(x, collector)
|
|
146
|
-
collector <<
|
|
156
|
+
collector << ', ' unless len == i
|
|
147
157
|
}
|
|
148
158
|
end
|
|
149
159
|
collector
|
|
@@ -205,7 +215,7 @@ module Arel
|
|
|
205
215
|
elsif Arel::Nodes::SqlLiteral === core.from
|
|
206
216
|
Arel::Table.new(core.from)
|
|
207
217
|
elsif Arel::Nodes::JoinSource === core.source
|
|
208
|
-
Arel::Nodes::SqlLiteral === core.source.left ? Arel::Table.new(core.source.left, @engine) : core.source.left
|
|
218
|
+
Arel::Nodes::SqlLiteral === core.source.left ? Arel::Table.new(core.source.left, @engine) : core.source.left.left
|
|
209
219
|
end
|
|
210
220
|
end
|
|
211
221
|
|