activerecord-sqlserver-adapter 5.0.1 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +16 -0
- data/README.md +1 -0
- data/VERSION +1 -1
- data/circle.yml +2 -0
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +3 -1
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +15 -11
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +5 -3
- data/test/bin/setup.sh +6 -4
- data/test/cases/specific_schema_test_sqlserver.rb +8 -0
- data/test/schema/sqlserver_specific_schema.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b2b6f7f8589a69b587c63d0de5713b527e2389f
|
4
|
+
data.tar.gz: 738c33f3937b47b7e87b54bf6436fcc81d3dbd4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65a7995a536eb3eedf3a771aff7c0645538189f131add85db6c585e43c03547ed64158009e53183310f05c8c9a5c40e8158baa79758f6bfcb0e5d7b680c472c5
|
7
|
+
data.tar.gz: 69eae26ecb4a8ccb7cc61e8b689e579ecae2046692de4fefe9978f2e36c4e1731231aec33b580545a521245041f3af9b9f833ec2ee9160874acbe723e1421019
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## v5.0.3
|
2
|
+
|
3
|
+
#### Changed
|
4
|
+
|
5
|
+
* Reduce view information reflection to per table vs. column. Fixes #552
|
6
|
+
* The `user_options` parsing. Works for hash/array. Fixes #535
|
7
|
+
* Pass the `:contained` option to TinyTDS. Fixes #527
|
8
|
+
|
9
|
+
|
10
|
+
## v5.0.2
|
11
|
+
|
12
|
+
#### Fixed
|
13
|
+
|
14
|
+
* Filter table constraints with matching table schema to column. Fixes #478
|
15
|
+
|
16
|
+
|
1
17
|
## v5.0.1
|
2
18
|
|
3
19
|
#### Changed
|
data/README.md
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
* [![CircleCI](https://circleci.com/gh/rails-sqlserver/activerecord-sqlserver-adapter/tree/master.svg?style=svg)](https://circleci.com/gh/rails-sqlserver/activerecord-sqlserver-adapter/tree/master) - CircleCI
|
6
6
|
* [![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
|
7
7
|
* [![Gem Version](http://img.shields.io/gem/v/activerecord-sqlserver-adapter.svg)](https://rubygems.org/gems/activerecord-sqlserver-adapter) - Gem Version
|
8
|
+
* [![Dependency Status](https://dependencyci.com/github/rails-sqlserver/activerecord-sqlserver-adapter/badge)](https://dependencyci.com/github/rails-sqlserver/activerecord-sqlserver-adapter) - Dependency Status
|
8
9
|
* [![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
|
9
10
|
|
10
11
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.0.
|
1
|
+
5.0.3
|
data/circle.yml
CHANGED
@@ -20,6 +20,7 @@ dependencies:
|
|
20
20
|
- tsql -C
|
21
21
|
- rvm-exec 2.2.5 bundle install
|
22
22
|
- rvm-exec 2.3.1 bundle install
|
23
|
+
- rvm-exec 2.4.0 bundle install
|
23
24
|
|
24
25
|
database:
|
25
26
|
override:
|
@@ -32,3 +33,4 @@ test:
|
|
32
33
|
override:
|
33
34
|
- rvm-exec 2.2.5 bundle exec rake test
|
34
35
|
- rvm-exec 2.3.1 bundle exec rake test
|
36
|
+
- rvm-exec 2.4.0 bundle exec rake test
|
@@ -132,7 +132,9 @@ module ActiveRecord
|
|
132
132
|
|
133
133
|
def user_options
|
134
134
|
return {} if sqlserver_azure?
|
135
|
-
select_rows('dbcc useroptions', 'SCHEMA')
|
135
|
+
rows = select_rows('dbcc useroptions', 'SCHEMA')
|
136
|
+
rows = rows.first if rows.size == 2 && rows.last.empty?
|
137
|
+
rows.reduce(HashWithIndifferentAccess.new) do |values, row|
|
136
138
|
if row.instance_of? Hash
|
137
139
|
set_option = row.values[0].gsub(/\s+/, '_')
|
138
140
|
user_value = row.values[1]
|
@@ -326,6 +326,7 @@ module ActiveRecord
|
|
326
326
|
FROM #{database}.INFORMATION_SCHEMA.COLUMNS columns
|
327
327
|
LEFT OUTER JOIN #{database}.INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC
|
328
328
|
ON TC.TABLE_NAME = columns.TABLE_NAME
|
329
|
+
AND TC.TABLE_SCHEMA = columns.TABLE_SCHEMA
|
329
330
|
AND TC.CONSTRAINT_TYPE = N'PRIMARY KEY'
|
330
331
|
LEFT OUTER JOIN #{database}.INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU
|
331
332
|
ON KCU.COLUMN_NAME = columns.COLUMN_NAME
|
@@ -469,20 +470,23 @@ module ActiveRecord
|
|
469
470
|
end
|
470
471
|
|
471
472
|
def view_information(table_name)
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
view_info =
|
476
|
-
if view_info
|
477
|
-
view_info
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
473
|
+
@view_information ||= {}
|
474
|
+
@view_information[table_name] ||= begin
|
475
|
+
identifier = SQLServer::Utils.extract_identifiers(table_name)
|
476
|
+
view_info = select_one "SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = '#{identifier.object}'", 'SCHEMA'
|
477
|
+
if view_info
|
478
|
+
view_info = view_info.with_indifferent_access
|
479
|
+
if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000
|
480
|
+
view_info[:VIEW_DEFINITION] = begin
|
481
|
+
select_values("EXEC sp_helptext #{identifier.object_quoted}", 'SCHEMA').join
|
482
|
+
rescue
|
483
|
+
warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;"
|
484
|
+
nil
|
485
|
+
end
|
482
486
|
end
|
483
487
|
end
|
488
|
+
view_info
|
484
489
|
end
|
485
|
-
view_info
|
486
490
|
end
|
487
491
|
|
488
492
|
def views_real_column_name(table_name, column_name)
|
@@ -176,11 +176,12 @@ module ActiveRecord
|
|
176
176
|
@connection.close rescue nil
|
177
177
|
end
|
178
178
|
@connection = nil
|
179
|
+
@spid = nil
|
180
|
+
@collation = nil
|
179
181
|
end
|
180
182
|
|
181
183
|
def clear_cache!
|
182
|
-
@
|
183
|
-
@collation = nil
|
184
|
+
@view_information = nil
|
184
185
|
super
|
185
186
|
end
|
186
187
|
|
@@ -362,7 +363,8 @@ module ActiveRecord
|
|
362
363
|
login_timeout: config_login_timeout(config),
|
363
364
|
timeout: config_timeout(config),
|
364
365
|
encoding: config_encoding(config),
|
365
|
-
azure: config[:azure]
|
366
|
+
azure: config[:azure],
|
367
|
+
contained: config[:contained]
|
366
368
|
).tap do |client|
|
367
369
|
if config[:azure]
|
368
370
|
client.execute('SET ANSI_NULLS ON').do
|
data/test/bin/setup.sh
CHANGED
@@ -3,15 +3,17 @@
|
|
3
3
|
set -x
|
4
4
|
set -e
|
5
5
|
|
6
|
-
|
6
|
+
tag=1.2
|
7
7
|
|
8
|
-
|
8
|
+
docker pull metaskills/mssql-server-linux-rails:$tag
|
9
|
+
|
10
|
+
container=$(docker ps -a -q --filter ancestor=metaskills/mssql-server-linux-rails:$tag)
|
9
11
|
if [[ -z $container ]]; then
|
10
|
-
docker run -p 1433:1433 -d metaskills/mssql-server-linux-rails && sleep 10
|
12
|
+
docker run -p 1433:1433 -d metaskills/mssql-server-linux-rails:$tag && sleep 10
|
11
13
|
exit
|
12
14
|
fi
|
13
15
|
|
14
|
-
container=$(docker ps -q --filter ancestor=metaskills/mssql-server-linux-rails)
|
16
|
+
container=$(docker ps -q --filter ancestor=metaskills/mssql-server-linux-rails:$tag)
|
15
17
|
if [[ -z $container ]]; then
|
16
18
|
docker start $container && sleep 10
|
17
19
|
fi
|
@@ -165,4 +165,12 @@ class SpecificSchemaTestSQLServer < ActiveRecord::TestCase
|
|
165
165
|
db_uuid.must_match(acceptable_uuid)
|
166
166
|
end
|
167
167
|
|
168
|
+
# with similar table definition in two schemas
|
169
|
+
|
170
|
+
it 'returns the correct primary columns' do
|
171
|
+
connection = ActiveRecord::Base.connection
|
172
|
+
assert_equal 'field_1', connection.columns('test.sst_schema_test_mulitple_schema').detect(&:is_primary?).name
|
173
|
+
assert_equal 'field_2', connection.columns('test2.sst_schema_test_mulitple_schema').detect(&:is_primary?).name
|
174
|
+
end
|
175
|
+
|
168
176
|
end
|
@@ -204,4 +204,20 @@ ActiveRecord::Schema.define do
|
|
204
204
|
)
|
205
205
|
NATURALPKTABLESQLINOTHERSCHEMA
|
206
206
|
|
207
|
+
execute "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'sst_schema_test_mulitple_schema' and TABLE_SCHEMA = 'test') DROP TABLE test.sst_schema_test_mulitple_schema"
|
208
|
+
execute <<-SCHEMATESTMULTIPLESCHEMA
|
209
|
+
CREATE TABLE test.sst_schema_test_mulitple_schema(
|
210
|
+
field_1 int NOT NULL PRIMARY KEY,
|
211
|
+
field_2 int,
|
212
|
+
)
|
213
|
+
SCHEMATESTMULTIPLESCHEMA
|
214
|
+
execute "IF NOT EXISTS(SELECT * FROM sys.schemas WHERE name = 'test2') EXEC sp_executesql N'CREATE SCHEMA test2'"
|
215
|
+
execute "IF EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'sst_schema_test_mulitple_schema' and TABLE_SCHEMA = 'test2') DROP TABLE test2.sst_schema_test_mulitple_schema"
|
216
|
+
execute <<-SCHEMATESTMULTIPLESCHEMA
|
217
|
+
CREATE TABLE test2.sst_schema_test_mulitple_schema(
|
218
|
+
field_1 int,
|
219
|
+
field_2 int NOT NULL PRIMARY KEY,
|
220
|
+
)
|
221
|
+
SCHEMATESTMULTIPLESCHEMA
|
222
|
+
|
207
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-sqlserver-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2017-
|
17
|
+
date: 2017-02-02 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activerecord
|