activerecord-jdbc-alt-adapter 52.2.1-java → 52.6.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +22 -18
- data/Gemfile +1 -1
- data/README.md +16 -14
- data/Rakefile +30 -4
- data/activerecord-jdbc-adapter.gemspec +1 -1
- data/activerecord-jdbc-alt-adapter.gemspec +2 -2
- data/lib/activerecord-jdbc-alt-adapter.rb +1 -0
- data/lib/arjdbc/abstract/core.rb +1 -1
- data/lib/arjdbc/abstract/database_statements.rb +8 -21
- data/lib/arjdbc/jdbc.rb +0 -4
- data/lib/arjdbc/jdbc/column.rb +1 -5
- data/lib/arjdbc/mssql/adapter.rb +24 -11
- data/lib/arjdbc/mssql/connection_methods.rb +5 -0
- data/lib/arjdbc/mssql/database_statements.rb +1 -1
- data/lib/arjdbc/mssql/schema_statements.rb +1 -1
- data/lib/arjdbc/mysql/connection_methods.rb +13 -7
- data/lib/arjdbc/postgresql/column.rb +6 -3
- data/lib/arjdbc/postgresql/connection_methods.rb +3 -1
- data/lib/arjdbc/sqlite3/connection_methods.rb +1 -0
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/01-tomcat.rake +2 -2
- data/rakelib/02-test.rake +0 -2
- data/rakelib/rails.rake +1 -1
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +63 -9
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +282 -38
- data/src/java/arjdbc/util/DateTimeUtils.java +22 -8
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bbef112a6aaadd08c19169b2e2b1826e99a44f38f2d2b2e3b441383ab95b91b
|
4
|
+
data.tar.gz: 444be17b783f8b937d57cdbd47260b79f4d69a75117523b4848ec9171d082c85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc41292328eb23e4d84a13fcc5213c1a44780ee974c207b930ca17357304f7feef2497a3642c231ef350d91d371e631a108e72d74da8d5c734d5f3194257c76c
|
7
|
+
data.tar.gz: d2a6656b88aa2432a54b9de7b27066847136de6857b6848901d3f3551dd65f5aa92787dfc9f83c7e44195509faf86416eb59ef9a04627499dc4883388882df04
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,18 +1,27 @@
|
|
1
|
-
language: ruby
|
2
1
|
sudo: false
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
bundler_args: --without development
|
11
|
-
script: bundle exec rake ${TEST_PREFIX}test_$DB
|
2
|
+
dist: xenial
|
3
|
+
|
4
|
+
services:
|
5
|
+
- mysql
|
6
|
+
addons:
|
7
|
+
postgresql: 9.4
|
8
|
+
|
12
9
|
before_install:
|
13
10
|
- unset _JAVA_OPTIONS
|
14
11
|
- rvm @default,@global do gem uninstall bundler -a -x -I || true
|
15
12
|
- gem install bundler -v "~>1.17.3"
|
13
|
+
install:
|
14
|
+
- bundle install --retry 3 --without development
|
15
|
+
# to fix this issue: https://travis-ci.community/t/mariadb-10-1-fails-to-install-on-xenial/3151/3
|
16
|
+
- mysql -u root -e 'CREATE USER IF NOT EXISTS travis@localhost; GRANT ALL ON *.* TO travis@localhost;' || true
|
17
|
+
|
18
|
+
language: ruby
|
19
|
+
rvm:
|
20
|
+
- jruby-9.1.16.0
|
21
|
+
jdk:
|
22
|
+
- openjdk8
|
23
|
+
|
24
|
+
script: bundle exec rake ${TEST_PREFIX}test_$DB
|
16
25
|
before_script:
|
17
26
|
- echo "JAVA_OPTS=$JAVA_OPTS"
|
18
27
|
- export JRUBY_OPTS="-J-Xms64M -J-Xmx1024M"
|
@@ -38,12 +47,7 @@ before_script:
|
|
38
47
|
psql -c "create database activerecord_unittest;" -U postgres && \
|
39
48
|
psql -c "create database activerecord_unittest2;" -U postgres \
|
40
49
|
|| true
|
41
|
-
|
42
|
-
- jruby-9.1.16.0
|
43
|
-
jdk:
|
44
|
-
- openjdk8
|
45
|
-
addons:
|
46
|
-
postgresql: "9.4"
|
50
|
+
|
47
51
|
env:
|
48
52
|
- DB=mysql2 PREPARED_STATEMENTS=false
|
49
53
|
- DB=mysql2 PREPARED_STATEMENTS=true
|
@@ -86,10 +90,10 @@ matrix:
|
|
86
90
|
env: DB=sqlite3
|
87
91
|
# testing against MariaDB
|
88
92
|
- addons:
|
89
|
-
mariadb:
|
93
|
+
mariadb: 10.2
|
90
94
|
env: DB=mariadb PREPARED_STATEMENTS=false
|
91
95
|
- addons:
|
92
|
-
mariadb:
|
96
|
+
mariadb: 10.3
|
93
97
|
env: DB=mariadb PREPARED_STATEMENTS=true
|
94
98
|
# Rails test-suite :
|
95
99
|
- env: DB=mysql2 TEST_PREFIX="rails:" AR_VERSION="v5.2.3" # PS off by default
|
data/Gemfile
CHANGED
@@ -48,7 +48,7 @@ group :test do
|
|
48
48
|
gem 'mocha', '~> 1.2', require: false # Rails has '~> 0.14'
|
49
49
|
|
50
50
|
gem 'bcrypt', '~> 3.1.11', require: false
|
51
|
-
gem 'jdbc-mssql', '~> 0.
|
51
|
+
gem 'jdbc-mssql', '~> 0.7.0', require: nil
|
52
52
|
# gem 'pry-debugger-jruby', platform: :jruby
|
53
53
|
end
|
54
54
|
|
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
|
12
|
-
- For Rails `5.1.7` install the `51.
|
13
|
-
- For Rails `5.2.
|
11
|
+
- For Rails `5.0.7` install the `50.7.0` version of this adapter
|
12
|
+
- For Rails `5.1.7` install the `51.7.0` version of this adapter
|
13
|
+
- For Rails `5.2.4` install the `52.6.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', '~> 52.6.0'
|
28
|
+
gem 'jdbc-mssql', '~> 0.9.0'
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
@@ -117,15 +117,16 @@ this adapter should just work.
|
|
117
117
|
ActiveRecord-JDBC-Adapter (AR-JDBC) is the main database adapter for Rails'
|
118
118
|
*ActiveRecord* component that can be used with [JRuby][0].
|
119
119
|
ActiveRecord-JDBC-Adapter provides full or nearly full support for:
|
120
|
-
**MySQL**, **PostgreSQL**, **SQLite3
|
121
|
-
add support **MSSQL**. Unless we get more contributions we will not be going
|
122
|
-
beyond these four adapters. Note that the amount of work needed to get
|
123
|
-
another adapter is not huge but the amount of testing required to make sure
|
124
|
-
that adapter continues to work is not something we can do with the resources
|
125
|
-
we currently have.
|
120
|
+
**MySQL**, **PostgreSQL**, **SQLite3** and **MSSQL*** (SQLServer).
|
126
121
|
|
127
|
-
|
128
|
-
|
122
|
+
Unless we get more contributions we will not be supporting more adapters.
|
123
|
+
Note that the amount of work needed to get another adapter is not huge but
|
124
|
+
the amount of testing required to make sure that adapter continues to work
|
125
|
+
is not something we can do with the resources we currently have.
|
126
|
+
|
127
|
+
- for **Oracle** database users you are encouraged to use
|
128
|
+
https://github.com/rsim/oracle-enhanced
|
129
|
+
- **MSSQL** adapter's gem parts reside in a [separate repository][8]
|
129
130
|
|
130
131
|
Versions are targeted at certain versions of Rails and live on their own branches.
|
131
132
|
|
@@ -151,6 +152,7 @@ adapters are available:
|
|
151
152
|
- MySQL (`activerecord-jdbcmysql-adapter`)
|
152
153
|
- PostgreSQL (`activerecord-jdbcpostgresql-adapter`)
|
153
154
|
- SQLite3 (`activerecord-jdbcsqlite3-adapter`)
|
155
|
+
- MSSQL (`activerecord-jdbcsqlserver-adapter`)
|
154
156
|
|
155
157
|
2. If you're generating a new Rails application, use the following command:
|
156
158
|
|
@@ -285,4 +287,4 @@ license the database's drivers are licensed. See each driver gem's LICENSE.txt.
|
|
285
287
|
[5]: https://github.com/jruby/activerecord-jdbc-adapter/wiki
|
286
288
|
[6]: https://webchat.freenode.net/?channels=#jruby
|
287
289
|
[7]: http://badge.fury.io/rb/activerecord-jdbc-adapter
|
288
|
-
[8]: https://github.com/jruby/activerecord-
|
290
|
+
[8]: https://github.com/jruby/activerecord-jdbcsqlserver-adapter
|
data/Rakefile
CHANGED
@@ -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
|
+
|
1
27
|
require 'rake/clean'
|
2
28
|
|
3
29
|
CLEAN.include 'derby*', 'test.db.*', '*test.sqlite3', 'test/reports'
|
@@ -38,7 +64,8 @@ rake = lambda { |task| ruby "-S", "rake", task }
|
|
38
64
|
|
39
65
|
desc "Build #{gem_name} gem into the pkg directory."
|
40
66
|
task :build => :jar do
|
41
|
-
|
67
|
+
include_jar = ENV['INCLUDE_JAR_IN_GEM'] || 'true'
|
68
|
+
sh("INCLUDE_JAR_IN_GEM=#{include_jar} gem build -V '#{gemspec_path}'") do
|
42
69
|
gem_path = built_gem_path.call
|
43
70
|
file_name = File.basename(gem_path)
|
44
71
|
FileUtils.mkdir_p(File.join(base_dir, 'pkg'))
|
@@ -58,7 +85,6 @@ end
|
|
58
85
|
|
59
86
|
desc "Releasing AR-JDBC gems (use NOOP=true to disable gem pushing)"
|
60
87
|
task 'release:do' do
|
61
|
-
ENV['RELEASE'] = 'true' # so that .gemspec is built with adapter_java.jar
|
62
88
|
Rake::Task['build'].invoke
|
63
89
|
# Rake::Task['build:adapters'].invoke
|
64
90
|
|
@@ -257,7 +283,7 @@ if defined? JRUBY_VERSION
|
|
257
283
|
begin
|
258
284
|
require 'arjdbc/version'
|
259
285
|
rescue LoadError
|
260
|
-
path = File.expand_path('
|
286
|
+
path = File.expand_path('lib', File.dirname(__FILE__))
|
261
287
|
unless $LOAD_PATH.include?(path)
|
262
288
|
$LOAD_PATH << path; retry
|
263
289
|
end
|
@@ -297,7 +323,7 @@ if defined? JRUBY_VERSION
|
|
297
323
|
# class_files.gsub!('$', '\$') unless windows?
|
298
324
|
# args = class_files.map { |path| [ "-C #{classes_dir}", path ] }.flatten
|
299
325
|
|
300
|
-
if ENV['
|
326
|
+
if ENV['INCLUDE_JAR_IN_GEM'] == 'true'; require 'tempfile'
|
301
327
|
manifest = "Built-Time: #{Time.now.utc.strftime('%Y-%m-%d %H:%M:%S')}\n"
|
302
328
|
manifest += "Built-JRuby: #{JRUBY_VERSION}\n"
|
303
329
|
manifest += "Specification-Title: ActiveRecord-JDBC\n"
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
|
|
27
27
|
reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
|
28
28
|
gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
|
29
29
|
|
30
|
-
if ENV['
|
30
|
+
if ENV['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
|
31
31
|
gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
|
32
32
|
|
33
33
|
#gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.license = 'BSD-2-Clause'
|
12
12
|
gem.summary = 'ActiveRecord JDBC adapter, for use within JRuby on Rails and SQL Server'
|
13
13
|
gem.description = "" <<
|
14
|
-
"Fork of the ActiveRecord JDBC adapter with support for SQL Server
|
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
16
|
"AR-JDBC is a database adapter for Rails' ActiveRecord component designed " <<
|
17
17
|
"to be used with JRuby built upon Java's JDBC API for database access. " <<
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
29
29
|
reject { |f| f =~ /^(gemfiles)/ } # no tests - no Gemfile_s appraised ...
|
30
30
|
gem.files += ['lib/arjdbc/jdbc/adapter_java.jar'] #if ENV['RELEASE'].eql?('true')
|
31
31
|
|
32
|
-
if ENV['
|
32
|
+
if ENV['INCLUDE_JAR_IN_GEM'] != 'true' # @see Rakefile
|
33
33
|
gem.extensions << 'Rakefile' # to support auto-building .jar with :git paths
|
34
34
|
|
35
35
|
#gem.add_runtime_dependency 'jar-dependencies', '~> 0.1' # development not enough!
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'arjdbc'
|
data/lib/arjdbc/abstract/core.rb
CHANGED
@@ -10,11 +10,13 @@ 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)
|
13
|
+
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
14
|
+
|
13
15
|
if without_prepared_statement?(binds)
|
14
|
-
log(sql, name) { @connection.
|
16
|
+
log(sql, name) { @connection.execute_insert_pk(sql, pk) }
|
15
17
|
else
|
16
18
|
log(sql, name, binds) do
|
17
|
-
@connection.
|
19
|
+
@connection.execute_insert_pk(sql, binds, pk)
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -22,6 +24,8 @@ module ArJdbc
|
|
22
24
|
# It appears that at this point (AR 5.0) "prepare" should only ever be true
|
23
25
|
# if prepared statements are enabled
|
24
26
|
def exec_query(sql, name = nil, binds = NO_BINDS, prepare: false)
|
27
|
+
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
28
|
+
|
25
29
|
if without_prepared_statement?(binds)
|
26
30
|
log(sql, name) { @connection.execute_query(sql) }
|
27
31
|
else
|
@@ -34,6 +38,8 @@ module ArJdbc
|
|
34
38
|
end
|
35
39
|
|
36
40
|
def exec_update(sql, name = nil, binds = NO_BINDS)
|
41
|
+
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
42
|
+
|
37
43
|
if without_prepared_statement?(binds)
|
38
44
|
log(sql, name) { @connection.execute_update(sql) }
|
39
45
|
else
|
@@ -42,25 +48,6 @@ module ArJdbc
|
|
42
48
|
end
|
43
49
|
alias :exec_delete :exec_update
|
44
50
|
|
45
|
-
# overridden to support legacy binds
|
46
|
-
def insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])
|
47
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
48
|
-
super
|
49
|
-
end
|
50
|
-
alias create insert
|
51
|
-
|
52
|
-
# overridden to support legacy binds
|
53
|
-
def update(arel, name = nil, binds = [])
|
54
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
55
|
-
super
|
56
|
-
end
|
57
|
-
|
58
|
-
# overridden to support legacy binds
|
59
|
-
def delete(arel, name = nil, binds = [])
|
60
|
-
binds = convert_legacy_binds_to_attributes(binds) if binds.first.is_a?(Array)
|
61
|
-
super
|
62
|
-
end
|
63
|
-
|
64
51
|
def execute(sql, name = nil)
|
65
52
|
log(sql, name) { @connection.execute(sql) }
|
66
53
|
end
|
data/lib/arjdbc/jdbc.rb
CHANGED
@@ -2,12 +2,8 @@ require 'active_support/deprecation'
|
|
2
2
|
|
3
3
|
module ArJdbc
|
4
4
|
|
5
|
-
# @private
|
6
|
-
AR40 = ::ActiveRecord::VERSION::MAJOR > 3
|
7
5
|
# @private
|
8
6
|
AR42 = ::ActiveRecord::VERSION::STRING >= '4.2'
|
9
|
-
# @private
|
10
|
-
AR50 = ::ActiveRecord::VERSION::MAJOR > 4
|
11
7
|
|
12
8
|
# @private
|
13
9
|
AR52 = ::ActiveRecord::VERSION::STRING >= '5.2'
|
data/lib/arjdbc/jdbc/column.rb
CHANGED
@@ -28,17 +28,13 @@ module ActiveRecord
|
|
28
28
|
|
29
29
|
if ArJdbc::AR52
|
30
30
|
# undefined method `cast' for #<ActiveRecord::ConnectionAdapters::SqlTypeMetadata> on AR52
|
31
|
-
|
31
|
+
else
|
32
32
|
default = args[0].cast(default)
|
33
33
|
|
34
34
|
sql_type = args.delete_at(1)
|
35
35
|
type = args.delete_at(0)
|
36
36
|
|
37
37
|
args.unshift(SqlTypeMetadata.new(:sql_type => sql_type, :type => type))
|
38
|
-
elsif ArJdbc::AR42
|
39
|
-
default = args[0].type_cast_from_database(default)
|
40
|
-
else
|
41
|
-
default = default_value(default)
|
42
38
|
end
|
43
39
|
|
44
40
|
# super <= 4.1: (name, default, sql_type = nil, null = true)
|
data/lib/arjdbc/mssql/adapter.rb
CHANGED
@@ -85,6 +85,12 @@ module ActiveRecord
|
|
85
85
|
::ActiveRecord::ConnectionAdapters::MSSQLColumn
|
86
86
|
end
|
87
87
|
|
88
|
+
# Does this adapter support DDL rollbacks in transactions? That is, would
|
89
|
+
# CREATE TABLE or ALTER TABLE get rolled back by a transaction?
|
90
|
+
def supports_ddl_transactions?
|
91
|
+
true
|
92
|
+
end
|
93
|
+
|
88
94
|
# Does this adapter support creating foreign key constraints?
|
89
95
|
def supports_foreign_keys?
|
90
96
|
true
|
@@ -100,6 +106,16 @@ module ActiveRecord
|
|
100
106
|
true
|
101
107
|
end
|
102
108
|
|
109
|
+
# Does this adapter support index sort order?
|
110
|
+
def supports_index_sort_order?
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
# Also known as filtered index
|
115
|
+
def supports_partial_index?
|
116
|
+
true
|
117
|
+
end
|
118
|
+
|
103
119
|
# Does this adapter support views?
|
104
120
|
def supports_views?
|
105
121
|
true
|
@@ -116,6 +132,13 @@ module ActiveRecord
|
|
116
132
|
super
|
117
133
|
end
|
118
134
|
|
135
|
+
def reset!
|
136
|
+
# execute 'IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION'
|
137
|
+
# NOTE: it seems the above line interferes with the jdbc driver
|
138
|
+
# and ending up in connection closed, issue seen in rails 5.2 and 6.0
|
139
|
+
reconnect!
|
140
|
+
end
|
141
|
+
|
119
142
|
def disable_referential_integrity
|
120
143
|
tables = tables_with_referential_integrity
|
121
144
|
|
@@ -200,21 +223,11 @@ module ActiveRecord
|
|
200
223
|
end
|
201
224
|
|
202
225
|
def configure_connection
|
203
|
-
|
226
|
+
# Here goes initial settings per connection
|
204
227
|
|
205
228
|
set_session_transaction_isolation
|
206
229
|
end
|
207
230
|
|
208
|
-
def lock_timeout
|
209
|
-
timeout = config[:lock_timeout].to_i
|
210
|
-
|
211
|
-
if timeout.positive?
|
212
|
-
timeout
|
213
|
-
else
|
214
|
-
5_000
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
231
|
def set_session_transaction_isolation
|
219
232
|
isolation_level = config[:transaction_isolation]
|
220
233
|
|
@@ -52,6 +52,8 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
52
52
|
|
53
53
|
# @note Assumes SQLServer SQL-JDBC driver on the class-path.
|
54
54
|
def sqlserver_connection(config)
|
55
|
+
config = config.deep_dup
|
56
|
+
|
55
57
|
config[:adapter_spec] ||= ::ArJdbc::MSSQL
|
56
58
|
config[:adapter_class] = ActiveRecord::ConnectionAdapters::MSSQLAdapter unless config.key?(:adapter_class)
|
57
59
|
|
@@ -60,6 +62,7 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
60
62
|
config[:host] ||= 'localhost'
|
61
63
|
config[:driver] ||= 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
|
62
64
|
config[:connection_alive_sql] ||= 'SELECT 1'
|
65
|
+
config[:lock_timeout] ||= 5000
|
63
66
|
|
64
67
|
config[:url] ||= begin
|
65
68
|
url = "jdbc:sqlserver://#{config[:host]}"
|
@@ -67,6 +70,8 @@ ArJdbc::ConnectionMethods.module_eval do
|
|
67
70
|
url << "databaseName=#{config[:database]};" if config[:database]
|
68
71
|
url << "instanceName=#{config[:instance]};" if config[:instance]
|
69
72
|
url << "sendTimeAsDatetime=#{config[:send_time_as_datetime] || false};"
|
73
|
+
url << "loginTimeout=#{config[:login_timeout].to_i};" if config[:login_timeout]
|
74
|
+
url << "lockTimeout=#{config[:lock_timeout].to_i};"
|
70
75
|
app = config[:appname] || config[:application]
|
71
76
|
url << "applicationName=#{app};" if app
|
72
77
|
isc = config[:integrated_security] # Win only - needs sqljdbc_auth.dll
|