activerecord-sqlserver-adapter 7.1.0.beta1 → 7.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -3
- data/README.md +4 -4
- data/RUNNING_UNIT_TESTS.md +24 -10
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/sqlserver/database_statements.rb +14 -17
- data/lib/active_record/connection_adapters/sqlserver/schema_statements.rb +6 -3
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +2 -2
- data/test/cases/coerced_tests.rb +0 -74
- data/test/cases/transaction_test_sqlserver.rb +13 -8
- data/test/cases/view_test_sqlserver.rb +10 -6
- data/test/support/sql_counter_sqlserver.rb +0 -15
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42ca12c2b62c162e798e40d6ca3ec7861e736835d8d91f132eef16240dcfeb02
|
4
|
+
data.tar.gz: ddf249b287e32a11a03ea4b2a9bfe85dbbded619d83165559f108892d90da658
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dde118ab5b86cd3b154739ce66933e8d4f3380503e6626796941c93cd08775571ad1f6b1630d7a5882b8dc97e0cd5475a7043fd8ac792af723e7c85720ff2271
|
7
|
+
data.tar.gz: 80efec8b5e389f05c57a1a2bab01cae17addbda59ec772a602f9aa1e4212508301a954b32d795d0ec6898c161226d36664a169f834c3f34e3ce1fd1c34a56d0e
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,44 @@
|
|
1
|
-
## v7.1.0.
|
1
|
+
## v7.1.0.rc1
|
2
|
+
|
3
|
+
#### Added
|
4
|
+
|
5
|
+
* Rails 7.1 Support
|
6
|
+
|
7
|
+
The adapter supports new Rails 7.1 features such as composite primary keys. See the
|
8
|
+
[Rails 7.1 release notes](https://guides.rubyonrails.org/7_1_release_notes.html) for more information.
|
2
9
|
|
3
10
|
#### Changed
|
4
11
|
|
5
|
-
|
12
|
+
* Configure Connection
|
6
13
|
|
7
|
-
|
14
|
+
If you require additional connection configuration you now need to call `super` within the `configure_connection`
|
15
|
+
method so that the default configuration is also applied.
|
16
|
+
|
17
|
+
v7.1.x adapter:
|
18
|
+
```ruby
|
19
|
+
module ActiveRecord
|
20
|
+
module ConnectionAdapters
|
21
|
+
class SQLServerAdapter < AbstractAdapter
|
22
|
+
def configure_connection
|
23
|
+
super
|
24
|
+
raw_connection_do "SET TEXTSIZE #{64.megabytes}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
v7.0.x adapter:
|
32
|
+
```ruby
|
33
|
+
module ActiveRecord
|
34
|
+
module ConnectionAdapters
|
35
|
+
class SQLServerAdapter < AbstractAdapter
|
36
|
+
def configure_connection
|
37
|
+
raw_connection_do "SET TEXTSIZE #{64.megabytes}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
```
|
8
43
|
|
9
44
|
Please check [7-0-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/7-0-stable/CHANGELOG.md) for previous changes.
|
data/README.md
CHANGED
@@ -13,10 +13,10 @@ Interested in older versions? We follow a rational versioning policy that tracks
|
|
13
13
|
|
14
14
|
| Adapter Version | Rails Version | Support | Branch |
|
15
15
|
|-----------------|---------------|----------------|-------------------------------------------------------------------------------------------------|
|
16
|
-
| `
|
17
|
-
| `7.0.
|
18
|
-
| `6.1.
|
19
|
-
| `6.0.3` | `6.0.x` |
|
16
|
+
| `7.1.0.rc1` | `7.1.x` | In development | [main](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/main) |
|
17
|
+
| `7.0.5.1` | `7.0.x` | Active | [7-0-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/7-0-stable) |
|
18
|
+
| `6.1.3.0` | `6.1.x` | Active | [6-1-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-1-stable) |
|
19
|
+
| `6.0.3` | `6.0.x` | Ended | [6-0-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/6-0-stable) |
|
20
20
|
| `5.2.1` | `5.2.x` | Ended | [5-2-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-2-stable) |
|
21
21
|
| `5.1.6` | `5.1.x` | Ended | [5-1-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/5-1-stable) |
|
22
22
|
| `4.2.18` | `4.2.x` | Ended | [4-2-stable](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/4-2-stable) |
|
data/RUNNING_UNIT_TESTS.md
CHANGED
@@ -13,12 +13,12 @@ Default testing uses DBLIB with TinyTDS.
|
|
13
13
|
|
14
14
|
* Setup two databases in SQL Server, [activerecord_unittest] and [activerecord_unittest2]
|
15
15
|
* Create a [rails] user with an empty password and give it a [db_owner] role to both DBs. Some tests require a server role of [sysadmin] too. More details below with DDL SQL examples.
|
16
|
-
*
|
17
|
-
*
|
16
|
+
* `bundle install`
|
17
|
+
* `bundle exec rake test ACTIVERECORD_UNITTEST_HOST='my.db.net'`
|
18
18
|
|
19
19
|
Focusing tests. Use the `ONLY_` env vars to run either ours or the ActiveRecord cases. Use the `TEST_FILES` env variants to focus on specific test(s), use commas for multiple cases. Note, you have to use different env vars to focus only on ours or a core ActiveRecord case. There may be failures when focusing on an ActiveRecord case since our coereced test files is not loaded in this scenerio.
|
20
20
|
|
21
|
-
```
|
21
|
+
```console
|
22
22
|
$ bundle exec rake test ONLY_SQLSERVER=1
|
23
23
|
$ bundle exec rake test ONLY_ACTIVERECORD=1
|
24
24
|
|
@@ -49,13 +49,13 @@ GO
|
|
49
49
|
|
50
50
|
The tests of this adapter depend on the existence of the Rails which are automatically cloned for you with bundler. However you can clone Rails from git://github.com/rails/rails.git and set the `RAILS_SOURCE` environment variable so bundler will use another local path instead.
|
51
51
|
|
52
|
-
```
|
52
|
+
```console
|
53
53
|
$ git clone git://github.com/rails-sqlserver/activerecord-sqlserver-adapter.git
|
54
54
|
```
|
55
55
|
|
56
56
|
Suggest just letting bundler do all the work and assuming there is a git tag for the Rails version, you can set `RAILS_VERSION` before bundling.
|
57
57
|
|
58
|
-
```
|
58
|
+
```console
|
59
59
|
$ export RAILS_VERSION='4.2.0'
|
60
60
|
$ bundle install
|
61
61
|
```
|
@@ -65,20 +65,20 @@ $ bundle install
|
|
65
65
|
|
66
66
|
Please consult the `test/config.yml` file which is used to parse the configuration options for the DB connections when running tests. This file has overrides for any connection mode that you can set using simple environment variables. Assuming you are using FreeTDS 0.91 and above
|
67
67
|
|
68
|
-
```
|
68
|
+
```console
|
69
69
|
$ export ACTIVERECORD_UNITTEST_HOST='my.db.net' # Defaults to localhost
|
70
70
|
$ export ACTIVERECORD_UNITTEST_PORT='1533' # Defaults to 1433
|
71
71
|
```
|
72
72
|
|
73
73
|
If you have FreeTDS installed and/or want to use a named dataserver in your freetds.conf file
|
74
74
|
|
75
|
-
```
|
75
|
+
```console
|
76
76
|
$ export ACTIVERECORD_UNITTEST_DATASERVER='mydbname'
|
77
77
|
```
|
78
78
|
|
79
79
|
These can be passed down to rake too.
|
80
80
|
|
81
|
-
```
|
81
|
+
```console
|
82
82
|
$ bundle exec rake test ACTIVERECORD_UNITTEST_HOST='my.db.net'
|
83
83
|
```
|
84
84
|
|
@@ -87,16 +87,30 @@ $ bundle exec rake test ACTIVERECORD_UNITTEST_HOST='my.db.net'
|
|
87
87
|
|
88
88
|
Now with that out of the way you can run "bundle install" to hook everything up. Our tests use bundler to setup the load paths correctly. The default mode is DBLIB using TinyTDS. It is important to use bundle exec so we can wire up the ActiveRecord test libs correctly.
|
89
89
|
|
90
|
-
```
|
90
|
+
```console
|
91
91
|
$ bundle exec rake test
|
92
92
|
```
|
93
93
|
|
94
94
|
|
95
95
|
## Testing Options
|
96
96
|
|
97
|
-
|
98
97
|
By default, Bundler will download the Rails git repo and use the git tag that matches the dependency version in our gemspec. If you want to test another version of Rails, you can either temporarily change the :tag for Rails in the Gemfile. Likewise, you can clone the Rails repo your self to another directory and use the `RAILS_SOURCE` environment variable.
|
99
98
|
|
99
|
+
```console
|
100
|
+
$ RAILS_SOURCE='/vagrant/rails' bundle exec rake test
|
101
|
+
```
|
102
|
+
|
103
|
+
If you want to use a specific seed for the tests use the `TESTOPTS` env variable like:
|
104
|
+
|
105
|
+
```console
|
106
|
+
$ bundle exec rake test TESTOPTS="--seed=45250"
|
107
|
+
```
|
108
|
+
|
109
|
+
And to make the tests fail-fast use:
|
110
|
+
|
111
|
+
```console
|
112
|
+
$ bundle exec rake test TESTOPTS="-f"
|
113
|
+
```
|
100
114
|
|
101
115
|
## Troubleshooting
|
102
116
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
7.1.0.
|
1
|
+
7.1.0.rc1
|
@@ -43,21 +43,12 @@ module ActiveRecord
|
|
43
43
|
|
44
44
|
log(sql, name, binds, async: async) do
|
45
45
|
with_raw_connection do |conn|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
# TODO: Look into refactoring this.
|
50
|
-
if id_insert_table_name = query_requires_identity_insert?(sql)
|
51
|
-
with_identity_insert_enabled(id_insert_table_name, conn) do
|
52
|
-
handle = internal_raw_execute(sql, conn)
|
53
|
-
result = handle_to_names_and_values(handle, options)
|
54
|
-
end
|
55
|
-
else
|
56
|
-
handle = internal_raw_execute(sql, conn)
|
57
|
-
result = handle_to_names_and_values(handle, options)
|
46
|
+
if id_insert_table_name = query_requires_identity_insert?(sql)
|
47
|
+
with_identity_insert_enabled(id_insert_table_name, conn) do
|
48
|
+
result = internal_exec_sql_query(sql, conn)
|
58
49
|
end
|
59
|
-
|
60
|
-
|
50
|
+
else
|
51
|
+
result = internal_exec_sql_query(sql, conn)
|
61
52
|
end
|
62
53
|
end
|
63
54
|
end
|
@@ -65,6 +56,13 @@ module ActiveRecord
|
|
65
56
|
result
|
66
57
|
end
|
67
58
|
|
59
|
+
def internal_exec_sql_query(sql, conn)
|
60
|
+
handle = internal_raw_execute(sql, conn)
|
61
|
+
handle_to_names_and_values(handle, ar_result: true)
|
62
|
+
ensure
|
63
|
+
finish_statement_handle(handle)
|
64
|
+
end
|
65
|
+
|
68
66
|
def exec_delete(sql, name, binds)
|
69
67
|
sql = sql.dup << "; SELECT @@ROWCOUNT AS AffectedRows"
|
70
68
|
super(sql, name, binds).rows.first.first
|
@@ -400,10 +398,9 @@ module ActiveRecord
|
|
400
398
|
|
401
399
|
# === SQLServer Specific (Selecting) ============================ #
|
402
400
|
|
403
|
-
def _raw_select(sql, conn
|
401
|
+
def _raw_select(sql, conn)
|
404
402
|
handle = internal_raw_execute(sql, conn)
|
405
|
-
|
406
|
-
handle_to_names_and_values(handle, options)
|
403
|
+
handle_to_names_and_values(handle, fetch: :rows)
|
407
404
|
ensure
|
408
405
|
finish_statement_handle(handle)
|
409
406
|
end
|
@@ -640,17 +640,19 @@ module ActiveRecord
|
|
640
640
|
identifier = SQLServer::Utils.extract_identifiers(table_name)
|
641
641
|
information_query_table = identifier.database.present? ? "[#{identifier.database}].[INFORMATION_SCHEMA].[VIEWS]" : "[INFORMATION_SCHEMA].[VIEWS]"
|
642
642
|
view_info = select_one "SELECT * FROM #{information_query_table} WITH (NOLOCK) WHERE TABLE_NAME = #{quote(identifier.object)}", "SCHEMA"
|
643
|
+
|
643
644
|
if view_info
|
644
645
|
view_info = view_info.with_indifferent_access
|
645
646
|
if view_info[:VIEW_DEFINITION].blank? || view_info[:VIEW_DEFINITION].length == 4000
|
646
647
|
view_info[:VIEW_DEFINITION] = begin
|
647
|
-
|
648
|
+
select_values("EXEC sp_helptext #{identifier.object_quoted}", "SCHEMA").join
|
648
649
|
rescue
|
649
650
|
warn "No view definition found, possible permissions problem.\nPlease run GRANT VIEW DEFINITION TO your_user;"
|
650
651
|
nil
|
651
|
-
|
652
|
+
end
|
652
653
|
end
|
653
654
|
end
|
655
|
+
|
654
656
|
view_info
|
655
657
|
end
|
656
658
|
end
|
@@ -659,7 +661,8 @@ module ActiveRecord
|
|
659
661
|
view_definition = view_information(table_name)[:VIEW_DEFINITION]
|
660
662
|
return column_name unless view_definition
|
661
663
|
|
662
|
-
|
664
|
+
# Remove "CREATE VIEW ... AS SELECT ..." and then match the column name.
|
665
|
+
match_data = view_definition.sub(/CREATE\s+VIEW.*AS\s+SELECT\s/, '').match(/([\w-]*)\s+AS\s+#{column_name}\W/im)
|
663
666
|
match_data ? match_data[1] : column_name
|
664
667
|
end
|
665
668
|
|
@@ -501,7 +501,7 @@ module ActiveRecord
|
|
501
501
|
end
|
502
502
|
|
503
503
|
def sqlserver_version
|
504
|
-
@sqlserver_version ||= _raw_select("SELECT @@version", @raw_connection
|
504
|
+
@sqlserver_version ||= _raw_select("SELECT @@version", @raw_connection).first.first.to_s
|
505
505
|
end
|
506
506
|
|
507
507
|
private
|
@@ -526,7 +526,7 @@ module ActiveRecord
|
|
526
526
|
@raw_connection.execute("SET TEXTSIZE 2147483647").do
|
527
527
|
@raw_connection.execute("SET CONCAT_NULL_YIELDS_NULL ON").do
|
528
528
|
|
529
|
-
@spid = _raw_select("SELECT @@SPID", @raw_connection
|
529
|
+
@spid = _raw_select("SELECT @@SPID", @raw_connection).first.first
|
530
530
|
|
531
531
|
initialize_dateformatter
|
532
532
|
use_database
|
data/test/cases/coerced_tests.rb
CHANGED
@@ -923,34 +923,6 @@ class DefaultScopingTest < ActiveRecord::TestCase
|
|
923
923
|
coerce_tests! :test_order_in_default_scope_should_not_prevail
|
924
924
|
end
|
925
925
|
|
926
|
-
require "models/post"
|
927
|
-
require "models/subscriber"
|
928
|
-
class EachTest < ActiveRecord::TestCase
|
929
|
-
# Quoting in tests does not cope with bracket quoting.
|
930
|
-
# TODO: Remove coerced test when https://github.com/rails/rails/pull/49269 merged.
|
931
|
-
coerce_tests! :test_in_batches_no_subqueries_for_whole_tables_batching
|
932
|
-
def test_in_batches_no_subqueries_for_whole_tables_batching_coerced
|
933
|
-
c = Post.connection
|
934
|
-
quoted_posts_id = Regexp.escape(c.quote_table_name("posts.id"))
|
935
|
-
assert_sql(/DELETE FROM #{Regexp.escape(c.quote_table_name("posts"))} WHERE #{quoted_posts_id} > .+ AND #{quoted_posts_id} <=/i) do
|
936
|
-
Post.in_batches(of: 2).delete_all
|
937
|
-
end
|
938
|
-
end
|
939
|
-
|
940
|
-
# Quoting in tests does not cope with bracket quoting.
|
941
|
-
# TODO: Remove coerced test when https://github.com/rails/rails/pull/49269 merged.
|
942
|
-
coerce_tests! :test_in_batches_should_quote_batch_order
|
943
|
-
def test_in_batches_should_quote_batch_order_coerced
|
944
|
-
c = Post.connection
|
945
|
-
assert_sql(/ORDER BY #{Regexp.escape(c.quote_table_name('posts'))}\.#{Regexp.escape(c.quote_column_name('id'))}/) do
|
946
|
-
Post.in_batches(of: 1) do |relation|
|
947
|
-
assert_kind_of ActiveRecord::Relation, relation
|
948
|
-
assert_kind_of Post, relation.first
|
949
|
-
end
|
950
|
-
end
|
951
|
-
end
|
952
|
-
end
|
953
|
-
|
954
926
|
class EagerAssociationTest < ActiveRecord::TestCase
|
955
927
|
# Use LEN() instead of LENGTH() function.
|
956
928
|
coerce_tests! :test_count_with_include
|
@@ -2293,16 +2265,6 @@ class LogSubscriberTest < ActiveRecord::TestCase
|
|
2293
2265
|
end
|
2294
2266
|
end
|
2295
2267
|
|
2296
|
-
# TODO: Method `reset_column_information` does not exist. Comment out the test for the time being.
|
2297
|
-
# class ActiveRecordSchemaTest < ActiveRecord::TestCase
|
2298
|
-
# # Workaround for randomly failing test.
|
2299
|
-
# coerce_tests! :test_has_primary_key
|
2300
|
-
# def test_has_primary_key_coerced
|
2301
|
-
# @schema_migration.reset_column_information
|
2302
|
-
# original_test_has_primary_key
|
2303
|
-
# end
|
2304
|
-
# end
|
2305
|
-
|
2306
2268
|
class ReloadModelsTest < ActiveRecord::TestCase
|
2307
2269
|
# Skip test on Windows. The number of arguments passed to `IO.popen` in
|
2308
2270
|
# `activesupport/lib/active_support/testing/isolation.rb` exceeds what Windows can handle.
|
@@ -2533,37 +2495,6 @@ class InsertAllTest < ActiveRecord::TestCase
|
|
2533
2495
|
end
|
2534
2496
|
end
|
2535
2497
|
|
2536
|
-
class HasOneThroughDisableJoinsAssociationsTest < ActiveRecord::TestCase
|
2537
|
-
# TODO: Remove coerce after Rails 7.1.0 (see https://github.com/rails/rails/pull/44051)
|
2538
|
-
coerce_tests! :test_disable_joins_through_with_enum_type
|
2539
|
-
def test_disable_joins_through_with_enum_type_coerced
|
2540
|
-
joins = capture_sql { @member.club }
|
2541
|
-
no_joins = capture_sql { @member.club_without_joins }
|
2542
|
-
|
2543
|
-
assert_equal 1, joins.size
|
2544
|
-
assert_equal 2, no_joins.size
|
2545
|
-
|
2546
|
-
assert_match(/INNER JOIN/, joins.first)
|
2547
|
-
no_joins.each do |nj|
|
2548
|
-
assert_no_match(/INNER JOIN/, nj)
|
2549
|
-
end
|
2550
|
-
|
2551
|
-
assert_match(/\[memberships\]\.\[type\]/, no_joins.first)
|
2552
|
-
end
|
2553
|
-
end
|
2554
|
-
|
2555
|
-
class ActiveRecord::Encryption::EncryptableRecordTest < ActiveRecord::EncryptionTestCase
|
2556
|
-
# TODO: Remove coerce after Rails 7.1.0 (see https://github.com/rails/rails/pull/44052)
|
2557
|
-
# Same as original but SQL Server string is varchar(4000), not varchar(255) as other adapters. Produce invalid strings with 4001 characters
|
2558
|
-
coerce_tests! %r{validate column sizes}
|
2559
|
-
test "validate column sizes coerced" do
|
2560
|
-
assert EncryptedAuthor.new(name: "jorge").valid?
|
2561
|
-
assert_not EncryptedAuthor.new(name: "a" * 4001).valid?
|
2562
|
-
author = EncryptedAuthor.create(name: "a" * 4001)
|
2563
|
-
assert_not author.valid?
|
2564
|
-
end
|
2565
|
-
end
|
2566
|
-
|
2567
2498
|
module ActiveRecord
|
2568
2499
|
class Migration
|
2569
2500
|
class InvalidOptionsTest < ActiveRecord::TestCase
|
@@ -2654,8 +2585,3 @@ module ActiveRecord
|
|
2654
2585
|
end
|
2655
2586
|
end
|
2656
2587
|
end
|
2657
|
-
|
2658
|
-
# TODO: Need to uncoerce the 'SerializedAttributeTest' tests before releasing adapter for Rails 7.1
|
2659
|
-
class SerializedAttributeTest < ActiveRecord::TestCase
|
2660
|
-
coerce_all_tests!
|
2661
|
-
end
|
@@ -42,6 +42,9 @@ class TransactionTestSQLServer < ActiveRecord::TestCase
|
|
42
42
|
after_level = connection.user_options_isolation_level
|
43
43
|
_(in_level).must_match %r{serializable}i
|
44
44
|
_(after_level).must_match %r{read committed}i
|
45
|
+
ensure
|
46
|
+
# Reset all connections. Otherwise, the next test may fail with error 'DBPROCESS is dead or not enabled'. Not sure why.
|
47
|
+
ActiveRecord::Base.connection_handler.clear_all_connections!(:all)
|
45
48
|
end
|
46
49
|
|
47
50
|
it "can use an isolation level and reverts back to starting isolation level under exceptions" do
|
@@ -50,20 +53,16 @@ class TransactionTestSQLServer < ActiveRecord::TestCase
|
|
50
53
|
Ship.transaction(isolation: :serializable) { Ship.create! }
|
51
54
|
}).must_raise(ActiveRecord::RecordInvalid)
|
52
55
|
_(connection.user_options_isolation_level).must_match %r{read committed}i
|
56
|
+
ensure
|
57
|
+
# Reset all connections. Otherwise, the next test may fail with error 'DBPROCESS is dead or not enabled'. Not sure why.
|
58
|
+
ActiveRecord::Base.connection_handler.clear_all_connections!(:all)
|
53
59
|
end
|
54
60
|
|
55
61
|
describe "when READ_COMMITTED_SNAPSHOT is set" do
|
56
|
-
|
62
|
+
it "should use READ COMMITTED as an isolation level" do
|
57
63
|
connection.execute "ALTER DATABASE [#{connection.current_database}] SET ALLOW_SNAPSHOT_ISOLATION ON"
|
58
64
|
connection.execute "ALTER DATABASE [#{connection.current_database}] SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE"
|
59
|
-
end
|
60
|
-
|
61
|
-
after do
|
62
|
-
connection.execute "ALTER DATABASE [#{connection.current_database}] SET ALLOW_SNAPSHOT_ISOLATION OFF"
|
63
|
-
connection.execute "ALTER DATABASE [#{connection.current_database}] SET READ_COMMITTED_SNAPSHOT OFF WITH ROLLBACK IMMEDIATE"
|
64
|
-
end
|
65
65
|
|
66
|
-
it "should use READ COMMITTED as an isolation level" do
|
67
66
|
_(connection.user_options_isolation_level).must_match "read committed snapshot"
|
68
67
|
|
69
68
|
Ship.transaction(isolation: :serializable) do
|
@@ -74,6 +73,12 @@ class TransactionTestSQLServer < ActiveRecord::TestCase
|
|
74
73
|
# "READ COMMITTED", and that no exception was raised (it's reported back
|
75
74
|
# by SQL Server as "read committed snapshot").
|
76
75
|
_(connection.user_options_isolation_level).must_match "read committed snapshot"
|
76
|
+
ensure
|
77
|
+
connection.execute "ALTER DATABASE [#{connection.current_database}] SET ALLOW_SNAPSHOT_ISOLATION OFF"
|
78
|
+
connection.execute "ALTER DATABASE [#{connection.current_database}] SET READ_COMMITTED_SNAPSHOT OFF WITH ROLLBACK IMMEDIATE"
|
79
|
+
|
80
|
+
# Reset all connections. Otherwise, the next test may fail with error 'DBPROCESS is dead or not enabled'. Not sure why.
|
81
|
+
ActiveRecord::Base.connection_handler.clear_all_connections!(:all)
|
77
82
|
end
|
78
83
|
end
|
79
84
|
|
@@ -9,18 +9,20 @@ class ViewTestSQLServer < ActiveRecord::TestCase
|
|
9
9
|
before do
|
10
10
|
connection.drop_table :view_casing_table rescue nil
|
11
11
|
connection.create_table :view_casing_table, force: true do |t|
|
12
|
-
t.boolean :Default_Falsey,
|
13
|
-
t.boolean :Default_Truthy,
|
14
|
-
t.string :
|
12
|
+
t.boolean :Default_Falsey, null: false, default: false
|
13
|
+
t.boolean :Default_Truthy, null: false, default: true
|
14
|
+
t.string :default_string_null, null: true, default: nil
|
15
|
+
t.string :default_string, null: false, default: "abc"
|
15
16
|
end
|
16
17
|
|
17
18
|
connection.execute("DROP VIEW IF EXISTS view_casing_table_view;")
|
18
19
|
connection.execute <<-SQL
|
19
20
|
CREATE VIEW view_casing_table_view AS
|
20
21
|
SELECT id AS id,
|
21
|
-
default_falsey
|
22
|
-
default_truthy
|
23
|
-
|
22
|
+
default_falsey AS falsey,
|
23
|
+
default_truthy AS truthy,
|
24
|
+
default_string_null AS s_null,
|
25
|
+
default_string AS s
|
24
26
|
FROM view_casing_table
|
25
27
|
SQL
|
26
28
|
end
|
@@ -34,12 +36,14 @@ class ViewTestSQLServer < ActiveRecord::TestCase
|
|
34
36
|
assert_equal false, obj.falsey
|
35
37
|
assert_equal true, obj.truthy
|
36
38
|
assert_equal "abc", obj.s
|
39
|
+
assert_nil obj.s_null
|
37
40
|
assert_equal 0, klass.count
|
38
41
|
|
39
42
|
obj.save!
|
40
43
|
assert_equal false, obj.falsey
|
41
44
|
assert_equal true, obj.truthy
|
42
45
|
assert_equal "abc", obj.s
|
46
|
+
assert_nil obj.s_null
|
43
47
|
assert_equal 1, klass.count
|
44
48
|
end
|
45
49
|
end
|
@@ -10,20 +10,5 @@ module ARTest
|
|
10
10
|
ActiveRecord::SQLCounter.log.dup
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
14
|
-
# TODO: Delete the code below after all Rails 6.1 tests passing.
|
15
|
-
#
|
16
|
-
# ignored_sql = [
|
17
|
-
# /INFORMATION_SCHEMA\.(TABLES|VIEWS|COLUMNS|KEY_COLUMN_USAGE)/im,
|
18
|
-
# /sys.columns/i,
|
19
|
-
# /SELECT @@version/,
|
20
|
-
# /SELECT @@TRANCOUNT/,
|
21
|
-
# /(BEGIN|COMMIT|ROLLBACK|SAVE) TRANSACTION/,
|
22
|
-
# /SELECT CAST\(.* AS .*\) AS value/,
|
23
|
-
# /SELECT DATABASEPROPERTYEX/im
|
24
|
-
# ]
|
25
|
-
#
|
26
|
-
# sqlcounter = ObjectSpace.each_object(ActiveRecord::SQLCounter).to_a.first
|
27
|
-
# sqlcounter.instance_variable_set :@ignore, Regexp.union(ignored_sql.push(sqlcounter.ignore))
|
28
13
|
end
|
29
14
|
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.1.0.
|
4
|
+
version: 7.1.0.rc1
|
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: 2023-11-
|
18
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activerecord
|
@@ -235,8 +235,8 @@ licenses:
|
|
235
235
|
- MIT
|
236
236
|
metadata:
|
237
237
|
bug_tracker_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues
|
238
|
-
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.1.0.
|
239
|
-
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.1.0.
|
238
|
+
changelog_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/blob/v7.1.0.rc1/CHANGELOG.md
|
239
|
+
source_code_uri: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/tree/v7.1.0.rc1
|
240
240
|
post_install_message:
|
241
241
|
rdoc_options: []
|
242
242
|
require_paths:
|