activerecord-sqlserver-adapter 8.1.2 → 8.1.4
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/.github/workflows/ci.yml +1 -7
- data/CHANGELOG.md +21 -0
- data/Gemfile +3 -3
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +10 -2
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +2 -1
- data/test/cases/adapter_test_sqlserver.rb +2 -0
- data/test/cases/change_column_null_test_sqlserver.rb +46 -16
- data/test/cases/coerced_tests.rb +77 -4
- data/test/cases/dbconsole_test_sqlserver.rb +19 -0
- data/test/cases/helper_sqlserver.rb +0 -1
- data/test/cases/schema_test_sqlserver.rb +32 -0
- metadata +5 -5
- data/test/cases/dbconsole.rb +0 -19
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b449fb9569a0dcfc91cc7e0109a29a145dc0c11b8488a3eb486650fa037eb2ad
|
|
4
|
+
data.tar.gz: ca39fe0127a4ab8e507b49c5a49f59ae02f193d6d54ae3f0d2e9f7731c6f4b08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5a25f54332ba7e594ceef724da573ef3add3820e7f7de4dcc3a59622c77b5a5978a433efa42894f9467d8940024e11345022d556522a2000289a5f2046cd012
|
|
7
|
+
data.tar.gz: ed563ea7651fb586b42c3d59f17d8459b73245ebf014b9121a85baff1584a405a4ec72e8a1a005cbf57c9e0fa84f8a5c8ad4b20c3d451a5490e58b19f34af394
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## v8.1.4
|
|
2
|
+
|
|
3
|
+
#### Fixed
|
|
4
|
+
|
|
5
|
+
- [#1418](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1418) Fix `change_column_null` to re-declare datetime2 columns correctly.
|
|
6
|
+
|
|
7
|
+
#### Changed
|
|
8
|
+
|
|
9
|
+
- [#1405](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1405) Fix `insert_all`/`upsert_all` for single character, temporary, non-ASCII and three part table names, and stop an aliased target being included in the `MERGE` table name.
|
|
10
|
+
|
|
11
|
+
## v8.1.3
|
|
12
|
+
|
|
13
|
+
#### Added
|
|
14
|
+
|
|
15
|
+
- [#1383](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1383) Support trust_server_certificate option in dbconsole.
|
|
16
|
+
|
|
17
|
+
#### Changed
|
|
18
|
+
|
|
19
|
+
- [#1393](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1393) Treat TinyTDS `failed dbsqlsend() function` errors as `ConnectionNotEstablished` so they're retried instead of surfaced as `StatementInvalid`.
|
|
20
|
+
- [#1397](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1397) Treat "DBPROCESS is dead or not enabled" as ConnectionNotEstablished.
|
|
21
|
+
|
|
1
22
|
## v8.1.2
|
|
2
23
|
|
|
3
24
|
#### Fixed
|
data/Gemfile
CHANGED
|
@@ -9,9 +9,10 @@ gemspec
|
|
|
9
9
|
gem "bcrypt"
|
|
10
10
|
gem "pg", "1.5.9"
|
|
11
11
|
gem "sqlite3", ">= 2.1"
|
|
12
|
-
gem "tzinfo-data"
|
|
12
|
+
gem "tzinfo-data"
|
|
13
13
|
gem "benchmark-ips"
|
|
14
|
-
gem "minitest", "
|
|
14
|
+
gem "minitest", "~> 6.0"
|
|
15
|
+
gem "minitest-mock"
|
|
15
16
|
gem "msgpack", ">= 1.7.0"
|
|
16
17
|
|
|
17
18
|
if ENV["RAILS_SOURCE"]
|
|
@@ -61,7 +62,6 @@ end
|
|
|
61
62
|
|
|
62
63
|
group :development do
|
|
63
64
|
gem "minitest-spec-rails"
|
|
64
|
-
gem "mocha"
|
|
65
65
|
gem "pry-byebug", platform: [:mri, :mingw, :x64_mingw]
|
|
66
66
|
end
|
|
67
67
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
8.1.
|
|
1
|
+
8.1.4
|
|
@@ -4,6 +4,9 @@ module ActiveRecord
|
|
|
4
4
|
module ConnectionAdapters
|
|
5
5
|
module SQLServer
|
|
6
6
|
module SchemaStatements
|
|
7
|
+
MERGE_TARGET_IDENTIFIER = /(?:\[[^\]]+\]|[a-z0-9_-]+)/i # :nodoc:
|
|
8
|
+
MERGE_TARGET_TABLE_NAME = /\A\s*MERGE\s+INTO\s+(#{MERGE_TARGET_IDENTIFIER}(?:\s*\.#{MERGE_TARGET_IDENTIFIER}){0,2})\s+(?:AS|WITH|USING)/i # :nodoc:
|
|
9
|
+
|
|
7
10
|
def create_table(table_name, **options)
|
|
8
11
|
res = super
|
|
9
12
|
clear_cache!
|
|
@@ -411,7 +414,12 @@ module ActiveRecord
|
|
|
411
414
|
if !null.nil? && null == false && !default.nil?
|
|
412
415
|
execute("UPDATE #{table_id} SET #{column_id}=#{quote(default)} WHERE #{column_id} IS NULL")
|
|
413
416
|
end
|
|
414
|
-
|
|
417
|
+
|
|
418
|
+
# If datetime column has precision then it should be datetime2 column.
|
|
419
|
+
column_type = column.type
|
|
420
|
+
column_type = :datetime2 if column.type.to_s == "datetime" && !column.precision.nil?
|
|
421
|
+
|
|
422
|
+
sql = "ALTER TABLE #{table_id} ALTER COLUMN #{column_id} #{type_to_sql column_type, limit: column.limit, precision: column.precision, scale: column.scale}"
|
|
415
423
|
sql += " NOT NULL" if !null.nil? && null == false
|
|
416
424
|
|
|
417
425
|
execute sql
|
|
@@ -726,7 +734,7 @@ module ActiveRecord
|
|
|
726
734
|
elsif s.match?(/^\s*UPDATE\s+.*/i)
|
|
727
735
|
s.match(/UPDATE\s+([^(\s]+)\s*/i)[1]
|
|
728
736
|
elsif s.match?(/^\s*MERGE INTO.*/i)
|
|
729
|
-
s.match(
|
|
737
|
+
s.match(MERGE_TARGET_TABLE_NAME)[1]
|
|
730
738
|
else
|
|
731
739
|
s.match(/FROM[\s|(]+((\[[^(\]]+\])|[^(\s]+)\s*/i)[1]
|
|
732
740
|
end.strip
|
|
@@ -104,6 +104,7 @@ module ActiveRecord
|
|
|
104
104
|
args += ["-d", config.database.to_s] if config.database
|
|
105
105
|
args += ["-U", sqlserver_config[:username].to_s] if sqlserver_config[:username]
|
|
106
106
|
args += ["-P", sqlserver_config[:password].to_s] if sqlserver_config[:password]
|
|
107
|
+
args += ["-C"] if sqlserver_config[:trust_server_certificate]
|
|
107
108
|
|
|
108
109
|
if sqlserver_config[:host]
|
|
109
110
|
host_arg = "tcp:#{sqlserver_config[:host]}"
|
|
@@ -482,7 +483,7 @@ module ActiveRecord
|
|
|
482
483
|
|
|
483
484
|
def translate_exception(exception, message:, sql:, binds:)
|
|
484
485
|
case message
|
|
485
|
-
when /(SQL Server client is not connected)|(failed to execute statement)/i
|
|
486
|
+
when /(SQL Server client is not connected)|(failed to execute statement)|(failed dbsqlsend)|(DBPROCESS is dead or not enabled)/i
|
|
486
487
|
ConnectionNotEstablished.new(message, connection_pool: @pool)
|
|
487
488
|
when /(cannot insert duplicate key .* with unique index) | (violation of (unique|primary) key constraint)/i
|
|
488
489
|
RecordNotUnique.new(message, sql: sql, binds: binds, connection_pool: @pool)
|
|
@@ -230,6 +230,7 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
|
230
230
|
@identity_merge_sql = "MERGE INTO [ships] WITH (UPDLOCK, HOLDLOCK) AS target USING ( SELECT * FROM ( SELECT [id], [name], ROW_NUMBER() OVER ( PARTITION BY [id] ORDER BY [id] DESC ) AS rn_0 FROM ( VALUES (101, N'RSS Sir David Attenborough') ) AS t1 ([id], [name]) ) AS ranked_source WHERE rn_0 = 1 ) AS source ON (target.[id] = source.[id]) WHEN MATCHED THEN UPDATE SET target.[name] = source.[name] WHEN NOT MATCHED BY TARGET THEN INSERT ([id], [name]) VALUES (source.[id], source.[name]) OUTPUT INSERTED.[id]"
|
|
231
231
|
@identity_merge_sql_unquoted = "MERGE INTO ships WITH (UPDLOCK, HOLDLOCK) AS target USING ( SELECT * FROM ( SELECT id, name, ROW_NUMBER() OVER ( PARTITION BY id ORDER BY id DESC ) AS rn_0 FROM ( VALUES (101, N'RSS Sir David Attenborough') ) AS t1 (id, name) ) AS ranked_source WHERE rn_0 = 1 ) AS source ON (target.id = source.id) WHEN MATCHED THEN UPDATE SET target.name = source.name WHEN NOT MATCHED BY TARGET THEN INSERT (id, name) VALUES (source.id, source.name) OUTPUT INSERTED.id"
|
|
232
232
|
@identity_merge_sql_unordered = "MERGE INTO [ships] WITH (UPDLOCK, HOLDLOCK) AS target USING ( SELECT * FROM ( SELECT [name], [id], ROW_NUMBER() OVER ( PARTITION BY [id] ORDER BY [id] DESC ) AS rn_0 FROM ( VALUES (101, N'RSS Sir David Attenborough') ) AS t1 ([name], [id]) ) AS ranked_source WHERE rn_0 = 1 ) AS source ON (target.[id] = source.[id]) WHEN MATCHED THEN UPDATE SET target.[name] = source.[name] WHEN NOT MATCHED BY TARGET THEN INSERT ([name], [id]) VALUES (source.[name], source.[id]) OUTPUT INSERTED.[id]"
|
|
233
|
+
@identity_merge_sql_aliased_target = @identity_merge_sql.sub(" WITH (UPDLOCK, HOLDLOCK)", "")
|
|
233
234
|
|
|
234
235
|
@identity_insert_sql_non_dbo = "INSERT INTO [test].[aliens] ([id],[name]) VALUES(420,'Mork')"
|
|
235
236
|
@identity_insert_sql_non_dbo_unquoted = "INSERT INTO test.aliens ([id],[name]) VALUES(420,'Mork')"
|
|
@@ -253,6 +254,7 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
|
253
254
|
assert_equal "[ships]", connection.send(:query_requires_identity_insert?, @identity_merge_sql)
|
|
254
255
|
assert_equal "[ships]", connection.send(:query_requires_identity_insert?, @identity_merge_sql_unquoted)
|
|
255
256
|
assert_equal "[ships]", connection.send(:query_requires_identity_insert?, @identity_merge_sql_unordered)
|
|
257
|
+
assert_equal "[ships]", connection.send(:query_requires_identity_insert?, @identity_merge_sql_aliased_target)
|
|
256
258
|
|
|
257
259
|
assert_equal "[test].[aliens]", connection.send(:query_requires_identity_insert?, @identity_insert_sql_non_dbo)
|
|
258
260
|
assert_equal "[test].[aliens]", connection.send(:query_requires_identity_insert?, @identity_insert_sql_non_dbo_unquoted)
|
|
@@ -2,29 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
require "cases/helper_sqlserver"
|
|
4
4
|
require "migrations/create_clients_and_change_column_null"
|
|
5
|
+
require "cases/migration/helper"
|
|
5
6
|
|
|
6
7
|
class ChangeColumnNullTestSqlServer < ActiveRecord::TestCase
|
|
7
|
-
|
|
8
|
-
@old_verbose = ActiveRecord::Migration.verbose
|
|
9
|
-
ActiveRecord::Migration.verbose = false
|
|
10
|
-
CreateClientsAndChangeColumnNull.new.up
|
|
11
|
-
end
|
|
8
|
+
include ::ActiveRecord::Migration::TestHelper
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ActiveRecord::Migration.verbose = @old_verbose
|
|
10
|
+
def find_column(table, column_name)
|
|
11
|
+
connection.columns(table).find { |column| column.name == column_name.to_s }
|
|
16
12
|
end
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
describe "using migration" do
|
|
15
|
+
before do
|
|
16
|
+
@old_verbose = ActiveRecord::Migration.verbose
|
|
17
|
+
ActiveRecord::Migration.verbose = false
|
|
18
|
+
CreateClientsAndChangeColumnNull.new.up
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
after do
|
|
22
|
+
CreateClientsAndChangeColumnNull.new.down
|
|
23
|
+
ActiveRecord::Migration.verbose = @old_verbose
|
|
24
|
+
end
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let(:value_column) { find_column(clients_table, "value") }
|
|
26
|
+
let(:name_column) { find_column("clients", "name") }
|
|
27
|
+
let(:code_column) { find_column("clients", "code") }
|
|
28
|
+
let(:value_column) { find_column("clients", "value") }
|
|
26
29
|
|
|
27
|
-
describe "#change_column_null" do
|
|
28
30
|
it "does not change the column limit" do
|
|
29
31
|
_(name_column.limit).must_equal 15
|
|
30
32
|
end
|
|
@@ -41,4 +43,32 @@ class ChangeColumnNullTestSqlServer < ActiveRecord::TestCase
|
|
|
41
43
|
_(value_column.scale).must_equal 8
|
|
42
44
|
end
|
|
43
45
|
end
|
|
46
|
+
|
|
47
|
+
it "datetime2 column" do
|
|
48
|
+
add_column :test_models, :expiry_date, :datetime, precision: 6, null: true
|
|
49
|
+
|
|
50
|
+
_(find_column(:test_models, :expiry_date).sql_type).must_equal "datetime2(6)"
|
|
51
|
+
_(find_column(:test_models, :expiry_date).null).must_equal true
|
|
52
|
+
|
|
53
|
+
connection.change_column_null(:test_models, :expiry_date, false)
|
|
54
|
+
|
|
55
|
+
_(find_column(:test_models, :expiry_date).sql_type).must_equal "datetime2(6)"
|
|
56
|
+
_(find_column(:test_models, :expiry_date).null).must_equal false
|
|
57
|
+
ensure
|
|
58
|
+
remove_column("test_models", "expiry_date")
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "datetime column" do
|
|
62
|
+
add_column :test_models, :expiry_date, :datetime, precision: nil, null: true
|
|
63
|
+
|
|
64
|
+
_(find_column(:test_models, :expiry_date).sql_type).must_equal "datetime"
|
|
65
|
+
_(find_column(:test_models, :expiry_date).null).must_equal true
|
|
66
|
+
|
|
67
|
+
connection.change_column_null(:test_models, :expiry_date, false)
|
|
68
|
+
|
|
69
|
+
_(find_column(:test_models, :expiry_date).sql_type).must_equal "datetime"
|
|
70
|
+
_(find_column(:test_models, :expiry_date).null).must_equal false
|
|
71
|
+
ensure
|
|
72
|
+
remove_column("test_models", "expiry_date")
|
|
73
|
+
end
|
|
44
74
|
end
|
data/test/cases/coerced_tests.rb
CHANGED
|
@@ -77,6 +77,26 @@ class UniquenessValidationWithIndexTest < ActiveRecord::TestCase
|
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
+
module ActiveRecord
|
|
81
|
+
class Migration::IndexTest < ActiveRecord::TestCase
|
|
82
|
+
# SQL Server requires an explicit truthy comparison for BIT columns.
|
|
83
|
+
coerce_tests! :test_rename_index_preserves_where_clause
|
|
84
|
+
def test_rename_index_preserves_where_clause_coerced
|
|
85
|
+
skip unless connection.supports_partial_index?
|
|
86
|
+
|
|
87
|
+
# Keep the names short to make Oracle and similar behave.
|
|
88
|
+
connection.add_index(table_name, [:foo], name: "old_idx", where: "administrator = 1")
|
|
89
|
+
old_where = connection.indexes(table_name).find { |i| i.name == "old_idx" }.where
|
|
90
|
+
|
|
91
|
+
connection.rename_index(table_name, "old_idx", "new_idx")
|
|
92
|
+
|
|
93
|
+
new_index = connection.indexes(table_name).find { |i| i.name == "new_idx" }
|
|
94
|
+
assert_not_nil new_index
|
|
95
|
+
assert_equal old_where, new_index.where
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
80
100
|
module ActiveRecord
|
|
81
101
|
class AdapterTest < ActiveRecord::TestCase
|
|
82
102
|
# Legacy binds are not supported.
|
|
@@ -163,7 +183,7 @@ module ActiveRecord
|
|
|
163
183
|
# SQL Server does not allow truncation of tables that are referenced by foreign key
|
|
164
184
|
# constraints. So manually remove/add foreign keys in test.
|
|
165
185
|
coerce_tests! :test_truncate_tables_with_query_cache
|
|
166
|
-
def
|
|
186
|
+
def test_truncate_tables_with_query_cache_coerced
|
|
167
187
|
# Remove foreign key constraint to allow truncation.
|
|
168
188
|
@connection.remove_foreign_key :authors, :author_addresses
|
|
169
189
|
|
|
@@ -518,8 +538,8 @@ module ActiveRecord
|
|
|
518
538
|
five = columns.detect { |c| c.name == "five" }
|
|
519
539
|
|
|
520
540
|
assert_equal "hello", one.default
|
|
521
|
-
assert_equal true, two.
|
|
522
|
-
assert_equal false, three.
|
|
541
|
+
assert_equal true, two.cast_type.deserialize(two.default)
|
|
542
|
+
assert_equal false, three.cast_type.deserialize(three.default)
|
|
523
543
|
assert_equal 1, four.default
|
|
524
544
|
assert_equal "hello", five.default
|
|
525
545
|
end
|
|
@@ -2053,7 +2073,6 @@ class UnsafeRawSqlTest < ActiveRecord::TestCase
|
|
|
2053
2073
|
test "order: allows nested functions" do
|
|
2054
2074
|
ids_expected = Post.order(Arel.sql("author_id, len(trim(title))")).pluck(:id)
|
|
2055
2075
|
|
|
2056
|
-
# $DEBUG = true
|
|
2057
2076
|
ids = Post.order("author_id, len(trim(title))").pluck(:id)
|
|
2058
2077
|
|
|
2059
2078
|
assert_equal ids_expected, ids
|
|
@@ -2442,6 +2461,50 @@ class FieldOrderedValuesTest < ActiveRecord::TestCase
|
|
|
2442
2461
|
Book.where(author_id: nil, name: nil).delete_all
|
|
2443
2462
|
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
|
|
2444
2463
|
end
|
|
2464
|
+
|
|
2465
|
+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
|
|
2466
|
+
coerce_tests! :test_in_order_of_with_out_of_bound_integer_does_not_match_nulls
|
|
2467
|
+
def test_in_order_of_with_out_of_bound_integer_does_not_match_nulls_coerced
|
|
2468
|
+
Book.lease_connection.remove_index(:books, column: [:author_id, :name])
|
|
2469
|
+
|
|
2470
|
+
original_test_in_order_of_with_out_of_bound_integer_does_not_match_nulls
|
|
2471
|
+
ensure
|
|
2472
|
+
Book.where(author_id: nil, name: nil).delete_all
|
|
2473
|
+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
|
|
2474
|
+
end
|
|
2475
|
+
|
|
2476
|
+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
|
|
2477
|
+
coerce_tests! :test_in_order_of_with_only_unrepresentable_values_does_not_build_empty_case
|
|
2478
|
+
def test_in_order_of_with_only_unrepresentable_values_does_not_build_empty_case_coerced
|
|
2479
|
+
Book.lease_connection.remove_index(:books, column: [:author_id, :name])
|
|
2480
|
+
|
|
2481
|
+
original_test_in_order_of_with_only_unrepresentable_values_does_not_build_empty_case
|
|
2482
|
+
ensure
|
|
2483
|
+
Book.where(author_id: nil, name: nil).delete_all
|
|
2484
|
+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
|
|
2485
|
+
end
|
|
2486
|
+
|
|
2487
|
+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
|
|
2488
|
+
coerce_tests! :test_in_order_of_with_unknown_enum_key_does_not_match_nulls
|
|
2489
|
+
def test_in_order_of_with_unknown_enum_key_does_not_match_nulls_coerced
|
|
2490
|
+
Book.lease_connection.remove_index(:books, column: [:author_id, :name])
|
|
2491
|
+
|
|
2492
|
+
original_test_in_order_of_with_unknown_enum_key_does_not_match_nulls
|
|
2493
|
+
ensure
|
|
2494
|
+
Book.where(author_id: nil, name: nil).delete_all
|
|
2495
|
+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
|
|
2496
|
+
end
|
|
2497
|
+
|
|
2498
|
+
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
|
|
2499
|
+
coerce_tests! :test_in_order_of_with_column_from_cte
|
|
2500
|
+
def test_in_order_of_with_column_from_cte_coerced
|
|
2501
|
+
connection.remove_index(:books, column: [:author_id, :name])
|
|
2502
|
+
|
|
2503
|
+
original_test_in_order_of_with_column_from_cte
|
|
2504
|
+
ensure
|
|
2505
|
+
Book.where(author_id: nil, name: nil).delete_all
|
|
2506
|
+
Book.lease_connection.add_index(:books, [:author_id, :name], unique: true)
|
|
2507
|
+
end
|
|
2445
2508
|
end
|
|
2446
2509
|
|
|
2447
2510
|
class QueryLogsTest < ActiveRecord::TestCase
|
|
@@ -2837,3 +2900,13 @@ class EachTest < ActiveRecord::TestCase
|
|
|
2837
2900
|
end
|
|
2838
2901
|
end
|
|
2839
2902
|
end
|
|
2903
|
+
|
|
2904
|
+
class ActiveRecord::Encryption::EncryptableFixtureTest < ActiveRecord::EncryptionTestCase
|
|
2905
|
+
# Set the attribute as JSON type.
|
|
2906
|
+
::EncryptedBookWithJson.attribute :metadata, ActiveRecord::Type::SQLServer::Json.new
|
|
2907
|
+
|
|
2908
|
+
coerce_tests! %r{fixtures for json columns get encrypted automatically}
|
|
2909
|
+
def fixtures_for_json_columns_get_encrypted_automatically
|
|
2910
|
+
send(:"original_fixtures for json columns get encrypted automatically")
|
|
2911
|
+
end
|
|
2912
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class DbConsole < ActiveRecord::TestCase
|
|
4
|
+
subject { ActiveRecord::ConnectionAdapters::SQLServerAdapter }
|
|
5
|
+
|
|
6
|
+
it "uses sqlcmd to connect to database" do
|
|
7
|
+
assert_called_with(subject, :find_cmd_and_exec, ["sqlcmd", "-d", "db", "-U", "user", "-P", "secret", "-C", "-S", "tcp:localhost,1433"]) do
|
|
8
|
+
config = make_db_config(adapter: "sqlserver", database: "db", username: "user", password: "secret", host: "localhost", port: 1433, trust_server_certificate: true)
|
|
9
|
+
|
|
10
|
+
subject.dbconsole(config)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def make_db_config(config)
|
|
17
|
+
ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "primary", config)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -122,6 +122,38 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
|
|
|
122
122
|
it do
|
|
123
123
|
assert_equal "[with_numbers_1234]", connection.send(:get_raw_table_name, "MERGE INTO [with_numbers_1234] AS target")
|
|
124
124
|
end
|
|
125
|
+
|
|
126
|
+
it do
|
|
127
|
+
assert_equal "[dashboards]", connection.send(:get_raw_table_name, "MERGE INTO [dashboards] AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
it do
|
|
131
|
+
assert_equal "lock_without_defaults", connection.send(:get_raw_table_name, "MERGE INTO lock_without_defaults AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it do
|
|
135
|
+
assert_equal "[WITH - SPACES]", connection.send(:get_raw_table_name, "MERGE INTO [WITH - SPACES] AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
it do
|
|
139
|
+
assert_equal "[with].[select notation]", connection.send(:get_raw_table_name, "MERGE INTO [with].[select notation] AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
it do
|
|
143
|
+
assert_equal "[x]", connection.send(:get_raw_table_name, "MERGE INTO [x] WITH (UPDLOCK, HOLDLOCK) AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
it do
|
|
147
|
+
assert_equal "[with].[select notation]", connection.send(:get_raw_table_name, "MERGE INTO [with].[select notation] WITH (UPDLOCK, HOLDLOCK) AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
it do
|
|
151
|
+
assert_equal "[a].[dbo].[dashboards]", connection.send(:get_raw_table_name, "MERGE INTO [a].[dbo].[dashboards] WITH (UPDLOCK, HOLDLOCK) AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it do
|
|
155
|
+
assert_equal "with .dashboards", connection.send(:get_raw_table_name, "MERGE INTO with .dashboards WITH (UPDLOCK, HOLDLOCK) AS target USING (VALUES (1)) AS source ([id]) ON (target.[id] = source.[id]) WHEN NOT MATCHED THEN INSERT ([id]) VALUES (source.[id]);")
|
|
156
|
+
end
|
|
125
157
|
end
|
|
126
158
|
|
|
127
159
|
describe "CREATE VIEW statements" do
|
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: 8.1.
|
|
4
|
+
version: 8.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ken Collins
|
|
@@ -154,7 +154,7 @@ files:
|
|
|
154
154
|
- test/cases/coerced_tests.rb
|
|
155
155
|
- test/cases/column_test_sqlserver.rb
|
|
156
156
|
- test/cases/connection_test_sqlserver.rb
|
|
157
|
-
- test/cases/
|
|
157
|
+
- test/cases/dbconsole_test_sqlserver.rb
|
|
158
158
|
- test/cases/disconnected_test_sqlserver.rb
|
|
159
159
|
- test/cases/eager_load_too_many_ids_test_sqlserver.rb
|
|
160
160
|
- test/cases/enum_test_sqlserver.rb
|
|
@@ -245,8 +245,8 @@ licenses:
|
|
|
245
245
|
- MIT
|
|
246
246
|
metadata:
|
|
247
247
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
|
248
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v8.1.
|
|
249
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v8.1.
|
|
248
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v8.1.4/CHANGELOG.md
|
|
249
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v8.1.4
|
|
250
250
|
rdoc_options: []
|
|
251
251
|
require_paths:
|
|
252
252
|
- lib
|
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
261
261
|
- !ruby/object:Gem::Version
|
|
262
262
|
version: '0'
|
|
263
263
|
requirements: []
|
|
264
|
-
rubygems_version:
|
|
264
|
+
rubygems_version: 4.0.16
|
|
265
265
|
specification_version: 4
|
|
266
266
|
summary: ActiveRecord SQL Server Adapter.
|
|
267
267
|
test_files: []
|
data/test/cases/dbconsole.rb
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class DbConsole < ActiveRecord::TestCase
|
|
4
|
-
subject { ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter }
|
|
5
|
-
|
|
6
|
-
it "uses sqlplus to connect to database" do
|
|
7
|
-
subject.expects(:find_cmd_and_exec).with("sqlcmd", "-d", "db", "-U", "user", "-P", "secret", "-S", "tcp:localhost,1433")
|
|
8
|
-
|
|
9
|
-
config = make_db_config(adapter: "sqlserver", database: "db", username: "user", password: "secret", host: "localhost", port: 1433)
|
|
10
|
-
|
|
11
|
-
subject.dbconsole(config)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
def make_db_config(config)
|
|
17
|
-
ActiveRecord::DatabaseConfigurations::HashConfig.new("test", "primary", config)
|
|
18
|
-
end
|
|
19
|
-
end
|