activerecord-sqlserver-adapter 7.2.3 → 7.2.5
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/CHANGELOG.md +12 -0
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +19 -9
- data/lib/active_record/connection_adapters/sqlserver/utils.rb +4 -0
- data/test/cases/coerced_tests.rb +12 -0
- data/test/cases/schema_test_sqlserver.rb +6 -0
- data/test/cases/temporary_table_test_sqlserver.rb +19 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0c48184b9fac12f23a4db11b01d1ed3d670fdd48f8c9705c690c830b622f11e
|
4
|
+
data.tar.gz: 9e88d43c701da66870643b33684c9a2b2d58db063e419789d0b7faf6c5cf2e15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40567edb70c619f8b9ae007c41b9b1c05157862df8bb275494b1158648c87cad3971bc1d4080431696c623d48c42356cf826349b3cce36a762d9e7d68a0d3102
|
7
|
+
data.tar.gz: 162c65ce3cb0755f464798e0e55c651e72528f9e060c4dfd1d30ff8386fb54cbbe2f99c404f712a95c1567ec4892cc9833badcc73f8b4ce7469fdef8bdd2b039
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v7.2.5
|
2
|
+
|
3
|
+
#### Fixed
|
4
|
+
|
5
|
+
- [#1308](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1308) Fix retrieval of temporary table's column information.
|
6
|
+
|
7
|
+
## v7.2.4
|
8
|
+
|
9
|
+
#### Fixed
|
10
|
+
|
11
|
+
- [#1270](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/1270) Fix parsing of raw table name from SQL with extra parentheses
|
12
|
+
|
1
13
|
## v7.2.3
|
2
14
|
|
3
15
|
#### Fixed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.2.
|
1
|
+
7.2.5
|
@@ -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|
|
@@ -690,7 +700,7 @@ module ActiveRecord
|
|
690
700
|
elsif s.match?(/^\s*UPDATE\s+.*/i)
|
691
701
|
s.match(/UPDATE\s+([^\(\s]+)\s*/i)[1]
|
692
702
|
else
|
693
|
-
s.match(/FROM\s+((\[[^\(\]]+\])|[^\(\s]+)\s*/i)[1]
|
703
|
+
s.match(/FROM[\s|\(]+((\[[^\(\]]+\])|[^\(\s]+)\s*/i)[1]
|
694
704
|
end.strip
|
695
705
|
end
|
696
706
|
|
data/test/cases/coerced_tests.rb
CHANGED
@@ -376,6 +376,18 @@ module ActiveRecord
|
|
376
376
|
end
|
377
377
|
|
378
378
|
class CalculationsTest < ActiveRecord::TestCase
|
379
|
+
# SELECT columns must be in the GROUP clause.
|
380
|
+
coerce_tests! :test_should_count_with_group_by_qualified_name_on_loaded
|
381
|
+
def test_should_count_with_group_by_qualified_name_on_loaded_coerced
|
382
|
+
accounts = Account.group("accounts.id").select("accounts.id")
|
383
|
+
expected = { 1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1 }
|
384
|
+
assert_not_predicate accounts, :loaded?
|
385
|
+
assert_equal expected, accounts.count
|
386
|
+
accounts.load
|
387
|
+
assert_predicate accounts, :loaded?
|
388
|
+
assert_equal expected, accounts.count(:id)
|
389
|
+
end
|
390
|
+
|
379
391
|
# Fix randomly failing test. The loading of the model's schema was affecting the test.
|
380
392
|
coerce_tests! :test_offset_is_kept
|
381
393
|
def test_offset_is_kept_coerced
|
@@ -101,5 +101,11 @@ class SchemaTestSQLServer < ActiveRecord::TestCase
|
|
101
101
|
assert_equal "[with].[select notation]", connection.send(:get_raw_table_name, "INSERT INTO [with].[select notation] SELECT * FROM [table_name]")
|
102
102
|
end
|
103
103
|
end
|
104
|
+
|
105
|
+
describe 'CREATE VIEW statements' do
|
106
|
+
it do
|
107
|
+
assert_equal "test_table_as", connection.send(:get_raw_table_name, "CREATE VIEW test_views ( test_table_a_id, test_table_b_id ) AS SELECT test_table_as.id as test_table_a_id, test_table_bs.id as test_table_b_id FROM (test_table_as with(nolock) LEFT JOIN test_table_bs with(nolock) ON (test_table_as.id = test_table_bs.test_table_a_id))")
|
108
|
+
end
|
109
|
+
end
|
104
110
|
end
|
105
111
|
end
|
@@ -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
|
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.5
|
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:
|
18
|
+
date: 2025-03-10 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
|
@@ -239,8 +240,8 @@ licenses:
|
|
239
240
|
- MIT
|
240
241
|
metadata:
|
241
242
|
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.
|
243
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.2.5/CHANGELOG.md
|
244
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.2.5
|
244
245
|
post_install_message:
|
245
246
|
rdoc_options: []
|
246
247
|
require_paths:
|
@@ -295,6 +296,7 @@ test_files:
|
|
295
296
|
- test/cases/schema_test_sqlserver.rb
|
296
297
|
- test/cases/showplan_test_sqlserver.rb
|
297
298
|
- test/cases/specific_schema_test_sqlserver.rb
|
299
|
+
- test/cases/temporary_table_test_sqlserver.rb
|
298
300
|
- test/cases/transaction_test_sqlserver.rb
|
299
301
|
- test/cases/trigger_test_sqlserver.rb
|
300
302
|
- test/cases/utils_test_sqlserver.rb
|