activerecord-sqlserver-adapter 7.2.4 → 7.2.6
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 -1
- data/CHANGELOG.md +12 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +6 -6
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +18 -8
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +4 -0
- data/test/cases/temporary_table_test_sqlserver.rb +19 -0
- data/test/cases/view_test_sqlserver.rb +9 -3
- data/test/fixtures/sst_customers_view.yml +6 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c97e64045b3f48c88fb2bfaca1f2d6592f5e994fa2d97582847e7c159ea94256
|
4
|
+
data.tar.gz: 39c4c7fafd7a9cf6eb6dea39204cf51826532044bc8ae1477b2a844b9d85b4d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 317a59cbf7c2f55891b65a5d24a68b986f0b99a2610a630572c372344d0242b87de941eb81740497eda3ac0bde4bea44a638ea35f889ea9307cafc1d2cb8faf6
|
7
|
+
data.tar.gz: 5c20fa1cc28e1b27888e8759a1ae88bbffb638831696ef263765df3be50e491d4fab62c7bd5081c25da7a52dbf3e310885008b94f5608931e87af932038ffa4f
|
data/.github/workflows/ci.yml
CHANGED
@@ -5,7 +5,7 @@ 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
9
|
|
10
10
|
env:
|
11
11
|
COMPOSE_FILE: docker-compose.ci.yml
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v7.2.6
|
2
|
+
|
3
|
+
#### Fixed
|
4
|
+
|
5
|
+
- [#1333](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1333) Enable identity insert on view's base table for fixtures.
|
6
|
+
|
7
|
+
## v7.2.5
|
8
|
+
|
9
|
+
#### Fixed
|
10
|
+
|
11
|
+
- [#1308](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1308) Fix retrieval of temporary table's column information.
|
12
|
+
|
1
13
|
## v7.2.4
|
2
14
|
|
3
15
|
#### Fixed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.2.
|
1
|
+
7.2.6
|
@@ -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)
|
@@ -571,12 +571,22 @@ module ActiveRecord
|
|
571
571
|
end
|
572
572
|
|
573
573
|
def column_definitions_sql(database, identifier)
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
574
|
+
schema_name = "schema_name()"
|
575
|
+
|
576
|
+
if prepared_statements
|
577
|
+
object_name = "@0"
|
578
|
+
schema_name = "@1" if identifier.schema.present?
|
579
|
+
else
|
580
|
+
object_name = quote(identifier.object)
|
581
|
+
schema_name = quote(identifier.schema) if identifier.schema.present?
|
582
|
+
end
|
583
|
+
|
584
|
+
object_id_arg = identifier.schema.present? ? "CONCAT(#{schema_name},'.',#{object_name})" : object_name
|
585
|
+
|
586
|
+
if identifier.temporary_table?
|
587
|
+
database = "TEMPDB"
|
588
|
+
object_id_arg = "CONCAT('#{database}','..',#{object_name})"
|
589
|
+
end
|
580
590
|
|
581
591
|
%{
|
582
592
|
SELECT
|
@@ -631,7 +641,7 @@ module ActiveRecord
|
|
631
641
|
AND k.unique_index_id = ic.index_id
|
632
642
|
AND c.column_id = ic.column_id
|
633
643
|
WHERE
|
634
|
-
o.
|
644
|
+
o.Object_ID = Object_ID(#{object_id_arg})
|
635
645
|
AND s.name = #{schema_name}
|
636
646
|
ORDER BY
|
637
647
|
c.column_id
|
@@ -653,7 +663,7 @@ module ActiveRecord
|
|
653
663
|
end
|
654
664
|
|
655
665
|
def remove_default_constraint(table_name, column_name)
|
656
|
-
# If
|
666
|
+
# If there are foreign keys in this table, we could still get back a 2D array, so flatten just in case.
|
657
667
|
execute_procedure(:sp_helpconstraint, table_name, "nomsg").flatten.select do |row|
|
658
668
|
row["constraint_type"] == "DEFAULT on column #{column_name}"
|
659
669
|
end.each do |row|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "cases/helper_sqlserver"
|
4
|
+
|
5
|
+
class TemporaryTableSQLServer < ActiveRecord::TestCase
|
6
|
+
def test_insert_into_temporary_table
|
7
|
+
ActiveRecord::Base.with_connection do |conn|
|
8
|
+
conn.exec_query("CREATE TABLE #temp_users (id INT IDENTITY(1,1), name NVARCHAR(100))")
|
9
|
+
|
10
|
+
result = conn.exec_query("SELECT * FROM #temp_users")
|
11
|
+
assert_equal 0, result.count
|
12
|
+
|
13
|
+
conn.exec_query("INSERT INTO #temp_users (name) VALUES ('John'), ('Doe')")
|
14
|
+
|
15
|
+
result = conn.exec_query("SELECT * FROM #temp_users")
|
16
|
+
assert_equal 2, result.count
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Collins
|
@@ -15,7 +15,7 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2025-
|
18
|
+
date: 2025-05-20 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- test/cases/schema_test_sqlserver.rb
|
178
178
|
- test/cases/showplan_test_sqlserver.rb
|
179
179
|
- test/cases/specific_schema_test_sqlserver.rb
|
180
|
+
- test/cases/temporary_table_test_sqlserver.rb
|
180
181
|
- test/cases/transaction_test_sqlserver.rb
|
181
182
|
- test/cases/trigger_test_sqlserver.rb
|
182
183
|
- test/cases/utils_test_sqlserver.rb
|
@@ -185,6 +186,7 @@ files:
|
|
185
186
|
- test/config.yml
|
186
187
|
- test/debug.rb
|
187
188
|
- test/fixtures/1px.gif
|
189
|
+
- test/fixtures/sst_customers_view.yml
|
188
190
|
- test/migrations/create_clients_and_change_column_collation.rb
|
189
191
|
- test/migrations/create_clients_and_change_column_null.rb
|
190
192
|
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|
@@ -239,8 +241,8 @@ licenses:
|
|
239
241
|
- MIT
|
240
242
|
metadata:
|
241
243
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
242
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.
|
243
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.
|
244
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.6/CHANGELOG.md
|
245
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.6
|
244
246
|
post_install_message:
|
245
247
|
rdoc_options: []
|
246
248
|
require_paths:
|
@@ -295,6 +297,7 @@ test_files:
|
|
295
297
|
- test/cases/schema_test_sqlserver.rb
|
296
298
|
- test/cases/showplan_test_sqlserver.rb
|
297
299
|
- test/cases/specific_schema_test_sqlserver.rb
|
300
|
+
- test/cases/temporary_table_test_sqlserver.rb
|
298
301
|
- test/cases/transaction_test_sqlserver.rb
|
299
302
|
- test/cases/trigger_test_sqlserver.rb
|
300
303
|
- test/cases/utils_test_sqlserver.rb
|
@@ -303,6 +306,7 @@ test_files:
|
|
303
306
|
- test/config.yml
|
304
307
|
- test/debug.rb
|
305
308
|
- test/fixtures/1px.gif
|
309
|
+
- test/fixtures/sst_customers_view.yml
|
306
310
|
- test/migrations/create_clients_and_change_column_collation.rb
|
307
311
|
- test/migrations/create_clients_and_change_column_null.rb
|
308
312
|
- test/migrations/transaction_table/1_table_will_never_be_created.rb
|