activerecord-sqlserver-adapter 7.2.6 → 7.2.7
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 -0
- data/CHANGELOG.md +10 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +1 -1
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +3 -6
- data/test/cases/adapter_test_sqlserver.rb +25 -10
- data/test/cases/temp_test_sqlserver.rb +9 -0
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4cecbb9e30775c962ac1ce665548b88081fc41501177c3e96abb3739d5d3c8a
|
4
|
+
data.tar.gz: 46b36bbe894e2023475765deebcb2b0ff38af31c6341aff3c56920d5bed77e00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f978e149eb3c53fe1bd199fcbe533aef919dbbb6b076530e8a8d6e5e7dab9735a3f4ce98d3e27057ec2de18ba28c6a810b465f1b1525de14f75261226ca35b78
|
7
|
+
data.tar.gz: 8f30ad18a93884f2779d29850b19c2510c6a8c75455be38a25121912665355d799f2f1bb5d94664eb773b715ff45bb85e8244ec3afb4797f8dc5826b6c8f3f78
|
data/.github/workflows/ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## v7.2.7
|
2
|
+
|
3
|
+
#### Changed
|
4
|
+
|
5
|
+
- [#1341](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1341) Support more Azure services by changing language source.
|
6
|
+
|
7
|
+
#### Fixed
|
8
|
+
|
9
|
+
- [#1357](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1357) Support cross database inserts.
|
10
|
+
|
1
11
|
## v7.2.6
|
2
12
|
|
3
13
|
#### Fixed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.2.
|
1
|
+
7.2.7
|
@@ -228,7 +228,7 @@ module ActiveRecord
|
|
228
228
|
|
229
229
|
def user_options_dateformat
|
230
230
|
if sqlserver_azure?
|
231
|
-
select_value "SELECT [dateformat] FROM [sys].[syslanguages] WHERE [
|
231
|
+
select_value "SELECT [dateformat] FROM [sys].[syslanguages] WHERE [name] = @@LANGUAGE", "SCHEMA"
|
232
232
|
else
|
233
233
|
user_options["dateformat"]
|
234
234
|
end
|
@@ -571,6 +571,7 @@ module ActiveRecord
|
|
571
571
|
end
|
572
572
|
|
573
573
|
def column_definitions_sql(database, identifier)
|
574
|
+
database = "TEMPDB" if identifier.temporary_table?
|
574
575
|
schema_name = "schema_name()"
|
575
576
|
|
576
577
|
if prepared_statements
|
@@ -581,12 +582,8 @@ module ActiveRecord
|
|
581
582
|
schema_name = quote(identifier.schema) if identifier.schema.present?
|
582
583
|
end
|
583
584
|
|
584
|
-
object_id_arg = identifier.schema.present? ? "CONCAT(
|
585
|
-
|
586
|
-
if identifier.temporary_table?
|
587
|
-
database = "TEMPDB"
|
588
|
-
object_id_arg = "CONCAT('#{database}','..',#{object_name})"
|
589
|
-
end
|
585
|
+
object_id_arg = identifier.schema.present? ? "CONCAT('.',#{schema_name},'.',#{object_name})" : "CONCAT('..',#{object_name})"
|
586
|
+
object_id_arg = "CONCAT('#{database}',#{object_id_arg})"
|
590
587
|
|
591
588
|
%{
|
592
589
|
SELECT
|
@@ -7,10 +7,17 @@ require "models/post"
|
|
7
7
|
require "models/subscriber"
|
8
8
|
require "models/minimalistic"
|
9
9
|
require "models/college"
|
10
|
+
require "models/dog"
|
11
|
+
require "models/other_dog"
|
10
12
|
|
11
13
|
class AdapterTestSQLServer < ActiveRecord::TestCase
|
12
14
|
fixtures :tasks
|
13
15
|
|
16
|
+
let(:arunit_connection) { Topic.lease_connection }
|
17
|
+
let(:arunit2_connection) { College.lease_connection }
|
18
|
+
let(:arunit_database) { arunit_connection.pool.db_config.database }
|
19
|
+
let(:arunit2_database) { arunit2_connection.pool.db_config.database }
|
20
|
+
|
14
21
|
let(:basic_insert_sql) { "INSERT INTO [funny_jokes] ([name]) VALUES('Knock knock')" }
|
15
22
|
let(:basic_update_sql) { "UPDATE [customers] SET [address_street] = NULL WHERE [id] = 2" }
|
16
23
|
let(:basic_select_sql) { "SELECT * FROM [customers] WHERE ([customers].[id] = 1)" }
|
@@ -50,8 +57,7 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
50
57
|
assert Topic.table_exists?, "Topics table name of 'dbo.topics' should return true for exists."
|
51
58
|
|
52
59
|
# Test when database and owner included in table name.
|
53
|
-
|
54
|
-
Topic.table_name = "#{db_config.database}.dbo.topics"
|
60
|
+
Topic.table_name = "#{arunit_database}.dbo.topics"
|
55
61
|
assert Topic.table_exists?, "Topics table name of '[DATABASE].dbo.topics' should return true for exists."
|
56
62
|
ensure
|
57
63
|
Topic.table_name = "topics"
|
@@ -59,12 +65,6 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
59
65
|
end
|
60
66
|
|
61
67
|
it "test table existence across database schemas" do
|
62
|
-
arunit_connection = Topic.lease_connection
|
63
|
-
arunit2_connection = College.lease_connection
|
64
|
-
|
65
|
-
arunit_database = arunit_connection.pool.db_config.database
|
66
|
-
arunit2_database = arunit2_connection.pool.db_config.database
|
67
|
-
|
68
68
|
# Assert that connections use different default databases schemas.
|
69
69
|
assert_not_equal arunit_database, arunit2_database
|
70
70
|
|
@@ -200,6 +200,9 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
200
200
|
@identity_insert_sql_non_dbo_sp = "EXEC sp_executesql N'INSERT INTO [test].[aliens] ([id],[name]) VALUES (@0, @1)', N'@0 int, @1 nvarchar(255)', @0 = 420, @1 = N'Mork'"
|
201
201
|
@identity_insert_sql_non_dbo_unquoted_sp = "EXEC sp_executesql N'INSERT INTO test.aliens (id, name) VALUES (@0, @1)', N'@0 int, @1 nvarchar(255)', @0 = 420, @1 = N'Mork'"
|
202
202
|
@identity_insert_sql_non_dbo_unordered_sp = "EXEC sp_executesql N'INSERT INTO [test].[aliens] ([name],[id]) VALUES (@0, @1)', N'@0 nvarchar(255), @1 int', @0 = N'Mork', @1 = 420"
|
203
|
+
|
204
|
+
@non_identity_insert_sql_cross_database = "INSERT INTO #{arunit2_database}.dbo.dogs SELECT * FROM #{arunit_database}.dbo.dogs"
|
205
|
+
@identity_insert_sql_cross_database = "INSERT INTO #{arunit2_database}.dbo.dogs(id) SELECT id FROM #{arunit_database}.dbo.dogs"
|
203
206
|
end
|
204
207
|
|
205
208
|
it "return quoted table_name to #query_requires_identity_insert? when INSERT sql contains id column" do
|
@@ -216,20 +219,32 @@ class AdapterTestSQLServer < ActiveRecord::TestCase
|
|
216
219
|
assert_equal "[test].[aliens]", connection.send(:query_requires_identity_insert?, @identity_insert_sql_non_dbo_sp)
|
217
220
|
assert_equal "[test].[aliens]", connection.send(:query_requires_identity_insert?, @identity_insert_sql_non_dbo_unquoted_sp)
|
218
221
|
assert_equal "[test].[aliens]", connection.send(:query_requires_identity_insert?, @identity_insert_sql_non_dbo_unordered_sp)
|
222
|
+
|
223
|
+
assert_equal "[#{arunit2_database}].[dbo].[dogs]", connection.send(:query_requires_identity_insert?, @identity_insert_sql_cross_database)
|
219
224
|
end
|
220
225
|
|
221
226
|
it "return false to #query_requires_identity_insert? for normal SQL" do
|
222
|
-
[basic_insert_sql, basic_update_sql, basic_select_sql].each do |sql|
|
227
|
+
[basic_insert_sql, basic_update_sql, basic_select_sql, @non_identity_insert_sql_cross_database].each do |sql|
|
223
228
|
assert !connection.send(:query_requires_identity_insert?, sql), "SQL was #{sql}"
|
224
229
|
end
|
225
230
|
end
|
226
231
|
|
227
|
-
it "find identity column
|
232
|
+
it "find identity column" do
|
228
233
|
task_id_column = Task.columns_hash["id"]
|
229
234
|
assert_equal task_id_column.name, connection.send(:identity_columns, Task.table_name).first.name
|
230
235
|
assert_equal task_id_column.sql_type, connection.send(:identity_columns, Task.table_name).first.sql_type
|
231
236
|
end
|
232
237
|
|
238
|
+
it "find identity column cross database" do
|
239
|
+
id_column = Dog.columns_hash["id"]
|
240
|
+
assert_equal id_column.name, arunit2_connection.send(:identity_columns, Dog.table_name).first.name
|
241
|
+
assert_equal id_column.sql_type, arunit2_connection.send(:identity_columns, Dog.table_name).first.sql_type
|
242
|
+
|
243
|
+
id_column = OtherDog.columns_hash["id"]
|
244
|
+
assert_equal id_column.name, arunit_connection.send(:identity_columns, OtherDog.table_name).first.name
|
245
|
+
assert_equal id_column.sql_type, arunit_connection.send(:identity_columns, OtherDog.table_name).first.sql_type
|
246
|
+
end
|
247
|
+
|
233
248
|
it "return an empty array when calling #identity_columns for a table_name with no identity" do
|
234
249
|
_(connection.send(:identity_columns, Subscriber.table_name)).must_equal []
|
235
250
|
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: 7.2.
|
4
|
+
version: 7.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
@@ -12,10 +12,9 @@ authors:
|
|
12
12
|
- Joe Rafaniello
|
13
13
|
- Tom Ward
|
14
14
|
- Aidan Haran
|
15
|
-
autorequire:
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
|
-
date:
|
17
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
19
18
|
dependencies:
|
20
19
|
- !ruby/object:Gem::Dependency
|
21
20
|
name: activerecord
|
@@ -177,6 +176,7 @@ files:
|
|
177
176
|
- test/cases/schema_test_sqlserver.rb
|
178
177
|
- test/cases/showplan_test_sqlserver.rb
|
179
178
|
- test/cases/specific_schema_test_sqlserver.rb
|
179
|
+
- test/cases/temp_test_sqlserver.rb
|
180
180
|
- test/cases/temporary_table_test_sqlserver.rb
|
181
181
|
- test/cases/transaction_test_sqlserver.rb
|
182
182
|
- test/cases/trigger_test_sqlserver.rb
|
@@ -241,9 +241,8 @@ licenses:
|
|
241
241
|
- MIT
|
242
242
|
metadata:
|
243
243
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
244
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.
|
245
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.
|
246
|
-
post_install_message:
|
244
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.7/CHANGELOG.md
|
245
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.7
|
247
246
|
rdoc_options: []
|
248
247
|
require_paths:
|
249
248
|
- lib
|
@@ -258,8 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
257
|
- !ruby/object:Gem::Version
|
259
258
|
version: '0'
|
260
259
|
requirements: []
|
261
|
-
rubygems_version: 3.
|
262
|
-
signing_key:
|
260
|
+
rubygems_version: 3.6.7
|
263
261
|
specification_version: 4
|
264
262
|
summary: ActiveRecord SQL Server Adapter.
|
265
263
|
test_files:
|
@@ -297,6 +295,7 @@ test_files:
|
|
297
295
|
- test/cases/schema_test_sqlserver.rb
|
298
296
|
- test/cases/showplan_test_sqlserver.rb
|
299
297
|
- test/cases/specific_schema_test_sqlserver.rb
|
298
|
+
- test/cases/temp_test_sqlserver.rb
|
300
299
|
- test/cases/temporary_table_test_sqlserver.rb
|
301
300
|
- test/cases/transaction_test_sqlserver.rb
|
302
301
|
- test/cases/trigger_test_sqlserver.rb
|