activerecord-sqlserver-adapter 7.2.5 → 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 +2 -1
- data/CHANGELOG.md +16 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +7 -7
- 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
- data/test/cases/view_test_sqlserver.rb +9 -3
- data/test/fixtures/sst_customers_view.yml +6 -0
- metadata +9 -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
@@ -5,7 +5,8 @@ on: [push, pull_request]
|
|
5
5
|
jobs:
|
6
6
|
test:
|
7
7
|
name: Run test suite
|
8
|
-
runs-on: ubuntu-
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
timeout-minutes: 10
|
9
10
|
|
10
11
|
env:
|
11
12
|
COMPOSE_FILE: docker-compose.ci.yml
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
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
|
+
|
11
|
+
## v7.2.6
|
12
|
+
|
13
|
+
#### Fixed
|
14
|
+
|
15
|
+
- [#1333](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1333) Enable identity insert on view's base table for fixtures.
|
16
|
+
|
1
17
|
## v7.2.5
|
2
18
|
|
3
19
|
#### Fixed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.2.
|
1
|
+
7.2.7
|
@@ -42,9 +42,6 @@ module ActiveRecord
|
|
42
42
|
log(sql, name, binds, async: async) do |notification_payload|
|
43
43
|
with_raw_connection do |conn|
|
44
44
|
result = if id_insert_table_name = query_requires_identity_insert?(sql)
|
45
|
-
# If the table name is a view, we need to get the base table name for enabling identity insert.
|
46
|
-
id_insert_table_name = view_table_name(id_insert_table_name) if view_exists?(id_insert_table_name)
|
47
|
-
|
48
45
|
with_identity_insert_enabled(id_insert_table_name, conn) do
|
49
46
|
internal_exec_sql_query(sql, conn)
|
50
47
|
end
|
@@ -194,11 +191,14 @@ module ActiveRecord
|
|
194
191
|
end
|
195
192
|
|
196
193
|
def with_identity_insert_enabled(table_name, conn)
|
197
|
-
|
198
|
-
|
194
|
+
# If the table name is a view, we need to get the base table name for enabling identity insert.
|
195
|
+
table_name = view_table_name(table_name) if view_exists?(table_name)
|
196
|
+
quoted_table_name = quote_table_name(table_name)
|
197
|
+
|
198
|
+
set_identity_insert(quoted_table_name, conn, true)
|
199
199
|
yield
|
200
200
|
ensure
|
201
|
-
set_identity_insert(
|
201
|
+
set_identity_insert(quoted_table_name, conn, false)
|
202
202
|
end
|
203
203
|
|
204
204
|
def use_database(database = nil)
|
@@ -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
|
@@ -48,11 +48,17 @@ class ViewTestSQLServer < ActiveRecord::TestCase
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
describe
|
52
|
-
it "
|
53
|
-
assert_difference("SSTestCustomersView.count",
|
51
|
+
describe "identity insert" do
|
52
|
+
it "creates table record through a view" do
|
53
|
+
assert_difference("SSTestCustomersView.count", 2) do
|
54
54
|
SSTestCustomersView.create!(id: 5, name: "Bob")
|
55
|
+
SSTestCustomersView.create!(id: 6, name: "Tim")
|
55
56
|
end
|
56
57
|
end
|
58
|
+
|
59
|
+
it "creates table records through a view using fixtures" do
|
60
|
+
ActiveRecord::FixtureSet.create_fixtures(File.join(ARTest::SQLServer.test_root_sqlserver, "fixtures"), ["sst_customers_view"])
|
61
|
+
assert_equal SSTestCustomersView.all.count, 2
|
62
|
+
end
|
57
63
|
end
|
58
64
|
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
|
@@ -186,6 +186,7 @@ files:
|
|
186
186
|
- test/config.yml
|
187
187
|
- test/debug.rb
|
188
188
|
- test/fixtures/1px.gif
|
189
|
+
- test/fixtures/sst_customers_view.yml
|
189
190
|
- test/migrations/create_clients_and_change_column_collation.rb
|
190
191
|
- test/migrations/create_clients_and_change_column_null.rb
|
191
192
|
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|
@@ -240,9 +241,8 @@ licenses:
|
|
240
241
|
- MIT
|
241
242
|
metadata:
|
242
243
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
243
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.
|
244
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.
|
245
|
-
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
|
246
246
|
rdoc_options: []
|
247
247
|
require_paths:
|
248
248
|
- lib
|
@@ -257,8 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
257
|
- !ruby/object:Gem::Version
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
|
-
rubygems_version: 3.
|
261
|
-
signing_key:
|
260
|
+
rubygems_version: 3.6.7
|
262
261
|
specification_version: 4
|
263
262
|
summary: ActiveRecord SQL Server Adapter.
|
264
263
|
test_files:
|
@@ -296,6 +295,7 @@ test_files:
|
|
296
295
|
- test/cases/schema_test_sqlserver.rb
|
297
296
|
- test/cases/showplan_test_sqlserver.rb
|
298
297
|
- test/cases/specific_schema_test_sqlserver.rb
|
298
|
+
- test/cases/temp_test_sqlserver.rb
|
299
299
|
- test/cases/temporary_table_test_sqlserver.rb
|
300
300
|
- test/cases/transaction_test_sqlserver.rb
|
301
301
|
- test/cases/trigger_test_sqlserver.rb
|
@@ -305,6 +305,7 @@ test_files:
|
|
305
305
|
- test/config.yml
|
306
306
|
- test/debug.rb
|
307
307
|
- test/fixtures/1px.gif
|
308
|
+
- test/fixtures/sst_customers_view.yml
|
308
309
|
- test/migrations/create_clients_and_change_column_collation.rb
|
309
310
|
- test/migrations/create_clients_and_change_column_null.rb
|
310
311
|
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|