Skip to content

Commit 64fd199

Browse files
authored
Merge branch 'master' into master
2 parents 1aafcc6 + 2eafd86 commit 64fd199

File tree

148 files changed

+3617
-2766
lines changed

Some content is hidden

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

148 files changed

+3617
-2766
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.github/issue_template.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## Issue
2+
<!-- Give a brief summary of the issue. -->
3+
4+
## Expected behavior
5+
<!-- Tell us what should happen -->
6+
7+
## Actual behavior
8+
<!-- Tell us what happens instead -->
9+
10+
## How to reproduce
11+
<!-- See https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/How-to-report-a-bug -->
12+
13+
## Details
14+
15+
- **Rails version**: `x.x.x`
16+
- **SQL Server adapter version**: `x.x.x`
17+
- **TinyTDS version**: `x.x.x`
18+
- **FreeTDS details**:
19+
20+
```
21+
run `tsql -C` and paste here the output.
22+
```
23+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ debug.log
33
.DS_Store
44
pkg/
55
doc/
6+
db/
67
*.gem
78
.bundle
89
Gemfile.lock

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
AllCops:
2+
TargetRubyVersion: 2.5
3+
4+
Layout/LineLength:
5+
Max: 120
6+
7+
Style/StringLiterals:
8+
EnforcedStyle: double_quotes

.travis.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ script:
1515
- docker-compose run ci
1616
matrix:
1717
include:
18-
- name: 2.3.8
19-
env: TARGET_VERSION=2.3.8
20-
- name: 2.4.6
21-
env: TARGET_VERSION=2.4.6
22-
- name: 2.5.5
23-
env: TARGET_VERSION=2.5.5
24-
- name: 2.6.3
25-
env: TARGET_VERSION=2.6.3
18+
- name: 2.5.8
19+
env: TARGET_VERSION=2.5.8
20+
- name: 2.6.6
21+
env: TARGET_VERSION=2.6.6
22+
- name: 2.7.1
23+
env: TARGET_VERSION=2.7.1

CHANGELOG.md

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
1-
## v5.2.0
2-
3-
- #686 sql_for_insert set table name in case when pk is not nil
4-
5-
## v5.2.0.rc2
1+
## v6.0.0.rc2 (unreleased)
62

73
#### Fixed
84

9-
- #681 change_column_null should not clear other column attributes. Fixes #582.
10-
- #684 Fix explain with array conditions. Fixes #673.
5+
- [#826](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/826) Rubocop: Enable Style/StringLiterals cop
6+
- [#827](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/827) Rubocop: Enable Layout/EmptyLinesAroundClassBody cop
7+
- [#828](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/828) Rubocop: Enable Layout/EmptyLines cop
8+
- [#829](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/829) Rubocop: Enable Layout/Layout/EmptyLinesAround* cops
9+
- [#830](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/830) Rubocop: Enable Layout/IndentationWidth and Layout/TrailingWhitespace cops
10+
- [#831](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/831) Rubocop: Enable Spacing cops
11+
- [#832](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/832) Rubocop: Enable Bundler cops
1112

12-
## v5.2.0.rc1
13+
## v6.0.0.rc1
1314

1415
#### Fixed
1516

16-
- #638 Don't disable referential integrity for the same table twice.
17-
- #646 Make String equality check work for Type::Data values. Fixes #645.
18-
- #671 Fix tinyint columns schema migration. Fixes #670.
17+
- [#690](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/690) Rails 6 support
18+
- [#805](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/805) Rails 6: Fix database tasks tests for SQL Server
19+
- [#807](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/807) Rails 6: Skip binary fixtures test on Windows
20+
- [#809](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/809) Rails 6: Coerce reaper test using fork
21+
- [#810](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/810) Rails 6: Fix randomly failing tests due to schema load
22+
- [#812](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/812) Rails 6: Coerce ReloadModelsTest test on Windows
23+
- [#818](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/818) Handle false return by TinyTDS if connection fails and fixed CI
24+
- [#819](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/819) Fix Ruby 2.7 kwargs warnings
25+
- [#825](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/825) Adjust error message when connection is dead
1926

2027
#### Changed
2128

22-
- #642 Added with (nolock) hint to information_schema.views.
29+
- [#716](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/716) Translate the connection timed out error
30+
- [#763](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/763) Refactor columns introspection query to make it faster
31+
- [#783](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/783) Update test matrix
32+
- [#820](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/820) Enable frozen strings for tests
33+
- [#821](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/821) Enable frozen strings - part 1
34+
- [#822](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/822) Enable frozen strings - part 2
35+
- [#823](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/823) Enable frozen strings - final
36+
- [#824](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/824) Tidy up Gemfile
37+
38+
#### Added
2339

40+
- [#726](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/726) How to Develop ActiveRecord SQL Server Adapter with Pre-Installed MS SQL
2441

25-
Please check [5-1-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/5-1-stable/CHANGELOG.md) for previous changes.
42+
Please check [5-2-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/5-2-stable/CHANGELOG.md) for previous changes.

Dockerfile renamed to Dockerfile.ci

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG TARGET_VERSION=2.6.3
22

3-
FROM wpolicarpo/activerecord-sqlserver-adapter:${TARGET_VERSION}
3+
FROM railssqlserver/activerecord-sqlserver-adapter:${TARGET_VERSION}
44

55
ENV WORKDIR /activerecord-sqlserver-adapter
66

Gemfile

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,69 @@
1-
require 'openssl'
2-
source 'https://rubygems.org'
3-
gemspec
1+
# frozen_string_literal: true
42

5-
gem 'sqlite3', '~> 1.3.6'
6-
gem 'bcrypt'
7-
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
3+
source "https://rubygems.org"
84

9-
if RbConfig::CONFIG["host_os"] =~ /darwin/
10-
gem 'terminal-notifier-guard'
11-
end
5+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
6+
7+
gemspec
128

13-
if ENV['RAILS_SOURCE']
14-
gemspec path: ENV['RAILS_SOURCE']
9+
gem "bcrypt"
10+
gem "pg", ">= 0.18.0"
11+
gem "sqlite3", "~> 1.4"
12+
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
13+
14+
if ENV["RAILS_SOURCE"]
15+
gemspec path: ENV["RAILS_SOURCE"]
1516
else
16-
# Need to get rails source beacause the gem doesn't include tests
17-
version = ENV['RAILS_VERSION'] || begin
18-
require 'net/http'
19-
require 'yaml'
20-
spec = eval(File.read('activerecord-sqlserver-adapter.gemspec'))
21-
ver = spec.dependencies.detect{ |d|d.name == 'activerecord' }.requirement.requirements.first.last.version
22-
major, minor, tiny, pre = ver.split('.')
23-
if !pre
24-
uri = URI.parse "https://rubygems.org/api/v1/versions/activerecord.yaml"
17+
# Need to get rails source because the gem doesn't include tests
18+
version = ENV["RAILS_VERSION"] || begin
19+
require "openssl"
20+
require "net/http"
21+
require "yaml"
22+
23+
spec = eval(File.read("activerecord-sqlserver-adapter.gemspec"))
24+
ver = spec.dependencies.detect { |d| d.name == "activerecord" }.requirement.requirements.first.last.version
25+
major, minor, tiny, pre = ver.split(".")
26+
27+
if pre
28+
ver
29+
else
30+
uri = URI.parse("https://rubygems.org/api/v1/versions/activerecord.yaml")
2531
http = Net::HTTP.new(uri.host, uri.port)
2632
http.use_ssl = true
2733
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
28-
YAML.load(http.request(Net::HTTP::Get.new(uri.request_uri)).body).select do |data|
29-
a, b, c = data['number'].split('.')
30-
!data['prerelease'] && major == a && (minor.nil? || minor == b)
31-
end.first['number']
32-
else
33-
ver
34+
YAML.load(http.request(Net::HTTP::Get.new(uri.request_uri)).body).find do |data|
35+
a, b, c = data["number"].split(".")
36+
!data["prerelease"] && major == a && (minor.nil? || minor == b)
37+
end["number"]
3438
end
3539
end
36-
gem 'rails', git: "git://github.com/rails/rails.git", tag: "v#{version}"
37-
end
38-
39-
if ENV['AREL']
40-
gem 'arel', path: ENV['AREL']
40+
gem "rails", github: "rails/rails", tag: "v#{version}"
4141
end
4242

43+
# rubocop:disable Bundler/DuplicatedGem
4344
group :tinytds do
44-
if ENV['TINYTDS_SOURCE']
45-
gem 'tiny_tds', path: ENV['TINYTDS_SOURCE']
46-
elsif ENV['TINYTDS_VERSION']
47-
gem 'tiny_tds', ENV['TINYTDS_VERSION']
45+
if ENV["TINYTDS_SOURCE"]
46+
gem "tiny_tds", path: ENV["TINYTDS_SOURCE"]
47+
elsif ENV["TINYTDS_VERSION"]
48+
gem "tiny_tds", ENV["TINYTDS_VERSION"]
4849
else
49-
gem 'tiny_tds'
50+
gem "tiny_tds"
5051
end
5152
end
53+
# rubocop:enable Bundler/DuplicatedGem
5254

5355
group :development do
54-
gem 'byebug'
55-
gem 'mocha'
56-
gem 'minitest-spec-rails'
56+
gem "minitest-spec-rails"
57+
gem "mocha"
58+
gem "pry-byebug", platform: [:mri, :mingw, :x64_mingw]
5759
end
5860

5961
group :guard do
60-
gem 'guard'
61-
gem 'guard-minitest'
62+
gem "guard"
63+
gem "guard-minitest"
64+
gem "terminal-notifier-guard" if RbConfig::CONFIG["host_os"] =~ /darwin/
65+
end
66+
67+
group :rubocop do
68+
gem "rubocop", require: false
6269
end

Guardfile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1+
# frozen_string_literal: true
12

2-
require_relative 'test/support/paths_sqlserver'
3+
require_relative "test/support/paths_sqlserver"
34

45
clearing :on
56
notification :terminal_notifier if defined?(TerminalNotifier)
67
ignore %r{debug\.log}
78

8-
ar_lib = File.join ARTest::SQLServer.root_activerecord, 'lib'
9-
ar_test = File.join ARTest::SQLServer.root_activerecord, 'test'
9+
ar_lib = File.join ARTest::SQLServer.root_activerecord, "lib"
10+
ar_test = File.join ARTest::SQLServer.root_activerecord, "test"
1011

1112
guard :minitest, {
1213
all_on_start: false,
1314
autorun: false,
14-
include: ['lib', 'test', ar_lib, ar_test],
15-
test_folders: ['test'],
15+
include: ["lib", "test", ar_lib, ar_test],
16+
test_folders: ["test"],
1617
test_file_patterns: ["*_test.rb", "*_test_sqlserver.rb"]
1718
} do
1819
# Our project watchers.
19-
if ENV['TEST_FILES']
20-
ENV['TEST_FILES'].split(',').map(&:strip).each do |file|
20+
if ENV["TEST_FILES"]
21+
ENV["TEST_FILES"].split(",").map(&:strip).each do |file|
2122
watch(%r{.*}) { file }
2223
end
2324
else
2425
watch(%r{^test/cases/\w+_test_sqlserver\.rb$})
2526
watch(%r{^test/cases/coerced_tests\.rb$}) { "test/cases/coerced_tests.rb" }
2627
watch(%r{^lib/active_record/connection_adapters/sqlserver/([^/]+)\.rb$}) { |m| "test/cases/#{m[1]}_test_sqlserver.rb" }
27-
watch(%r{^test/cases/helper_sqlserver\.rb$}) { 'test' }
28+
watch(%r{^test/cases/helper_sqlserver\.rb$}) { "test" }
2829
end
2930
end

README.md

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33
* [![TravisCI](https://travis-ci.org/rails-sqlserver/activerecord-sqlserver-adapter.svg?branch=master)](https://travis-ci.org/rails-sqlserver/activerecord-sqlserver-adapter) - TravisCI
44
* [![Build Status](https://ci.appveyor.com/api/projects/status/mtgbx8f57vr7k2qa/branch/master?svg=true)](https://ci.appveyor.com/project/rails-sqlserver/activerecord-sqlserver-adapter/branch/master) - Appveyor
55
* [![Gem Version](http://img.shields.io/gem/v/activerecord-sqlserver-adapter.svg)](https://rubygems.org/gems/activerecord-sqlserver-adapter) - Gem Version
6-
* [![Dependency Status](https://dependencyci.com/github/rails-sqlserver/activerecord-sqlserver-adapter/badge)](https://dependencyci.com/github/rails-sqlserver/activerecord-sqlserver-adapter) - Dependency Status
76
* [![Gitter chat](https://img.shields.io/badge/%E2%8A%AA%20GITTER%20-JOIN%20CHAT%20%E2%86%92-brightgreen.svg?style=flat)](https://gitter.im/rails-sqlserver/activerecord-sqlserver-adapter) - Community
87

98
## About The Adapter
109

11-
The SQL Server adapter for ActiveRecord v5.2 using SQL Server 2012 or higher.
10+
The SQL Server adapter for ActiveRecord v6.0 using SQL Server 2012 or higher.
1211

13-
Interested in older versions? We follow a rational versioning policy that tracks Rails. That means that our 5.1.x version of the adapter is only for the latest 5.1 version of Rails. If you need the adapter for SQL Server 2008 or 2005, you are still in the right spot. Just install the latest 3.2.x to 4.1.x version of the adapter that matches your Rails version. We also have stable branches for each major/minor release of ActiveRecord.
12+
Interested in older versions? We follow a rational versioning policy that tracks Rails. That means that our 5.2.x version of the adapter is only for the latest 5.2 version of Rails. If you need the adapter for SQL Server 2008 or 2005, you are still in the right spot. Just install the latest 3.2.x to 4.1.x version of the adapter that matches your Rails version. We also have stable branches for each major/minor release of ActiveRecord.
1413

1514
#### Native Data Type Support
1615

1716
We support every data type supported by FreeTDS. All simplified Rails types in migrations will coorespond to a matching SQL Server national (unicode) data type. Always check the `initialize_native_database_types` [(here)](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/master/lib/active_record/connection_adapters/sqlserver/schema_statements.rb) for an updated list.
1817

19-
The following types (date, datetime2, datetimeoffset, time) all require TDS version 7.3 with TinyTDS. We recommend using FreeTDS 1.0 or higher which default to using `TDSVER` to "7.3". The adapter also sets TinyTDS's `tds_version` to this as well if non is specified.
18+
The following types (`date`, `datetime2`, `datetimeoffset`, `time`) all require TDS version `7.3` with TinyTDS. We recommend using FreeTDS 1.0 or higher which default to using `TDSVER` to `7.3`. The adapter also sets TinyTDS's `tds_version` to this as well if non is specified.
2019

21-
The Rails v5 adapter supports ActiveRecord's `datetime_with_precision` setting. This means that passing `:precision` to a datetime column is supported. Using a pecision with the `:datetime` type will signal the adapter to use the `datetime2` type under the hood.
20+
The Rails v5 adapter supports ActiveRecord's `datetime_with_precision` setting. This means that passing `:precision` to a datetime column is supported. Using a precision with the `:datetime` type will signal the adapter to use the `datetime2` type under the hood.
2221

2322

2423
#### Identity Inserts with Triggers
@@ -81,9 +80,9 @@ end
8180
Every class that sub classes ActiveRecord::Base will now have an execute_procedure class method to use. This method takes the name of the stored procedure which can be a string or symbol and any number of variables to pass to the procedure. Arguments will automatically be quoted per the connection's standards as normal. For example:
8281

8382
```ruby
84-
Account.execute_procedure :update_totals, 'admin', nil, true
83+
Account.execute_procedure(:update_totals, 'admin', nil, true
8584
# Or with named parameters.
86-
Account.execute_procedure :update_totals, named: 'params'
85+
Account.execute_procedure(:update_totals, named: 'params')
8786
```
8887

8988
#### Explain Support (SHOWPLAN)
@@ -120,7 +119,7 @@ ActiveRecord::ConnectionAdapters::SQLServerAdapter.showplan_option = 'SHOWPLAN_X
120119

121120
## Installation
122121

123-
The adapter has no strict gem dependencies outside of ActiveRecord. You will have to pick a connection mode, the default is dblib which uses the TinyTDS gem. Just bundle the gem and the adapter will use it.
122+
The adapter has no strict gem dependencies outside of `ActiveRecord`. You will have to pick a connection mode, the default is dblib which uses the `TinyTDS` gem. Just bundle the gem and the adapter will use it.
124123

125124
```ruby
126125
gem 'tiny_tds'
@@ -140,30 +139,9 @@ If you would like to contribute a feature or bugfix, thanks! To make sure your f
140139

141140
Many many people have contributed. If you do not see your name here and it should be let us know. Also, many thanks go out to those that have pledged financial contributions.
142141

143-
144-
## Contributors
145-
146-
Up-to-date list of contributors: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/contributors
147-
148-
* metaskills (Ken Collins)
149-
* Annaswims (Annaswims)
150-
* wbond (Will Bond)
151-
* Thirdshift (Garrett Hart)
152-
* h-lame (Murray Steele)
153-
* vegantech
154-
* cjheath (Clifford Heath)
155-
* fryguy (Jason Frey)
156-
* jrafanie (Joe Rafaniello)
157-
* nerdrew (Andrew Ryan)
158-
* snowblink (Jonathan Lim)
159-
* koppen (Jakob Skjerning)
160-
* ebryn (Erik Bryn)
161-
* adzap (Adam Meehan)
162-
* neomindryan (Ryan Findley)
163-
* jeremydurham (Jeremy Durham)
164-
142+
You can see an up-to-date list of contributors here: http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/contributors
165143

166144
## License
167145

168-
Copyright © 2008-2017. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
146+
Copyright © 2008-2020. It is free software, and may be redistributed under the terms specified in the [MIT-LICENSE](MIT-LICENSE) file.
169147

0 commit comments

Comments
 (0)