Skip to content

Commit 0e8ff0e

Browse files
author
Anna
committed
outside_transaction? deprecated
1 parent b85ecec commit 0e8ff0e

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

lib/active_record/connection_adapters/sqlserver/database_statements.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def exec_query(sql, name = 'SQL', binds = [], sqlserver_options = {})
2525
end
2626
end
2727

28-
# TODO do something with added params. Rails 4 added 2 parameters and we're not using them.
28+
#The abstract adapter ignores the last two parameters also
2929
def exec_insert(sql, name, binds, pk = nil, sequence_name = nil)
3030
exec_query sql, name, binds, :insert => true
3131
end
@@ -39,10 +39,6 @@ def exec_update(sql, name, binds)
3939
sql << "; SELECT @@ROWCOUNT AS AffectedRows"
4040
super.rows.first.first
4141
end
42-
43-
def outside_transaction?
44-
select_value('SELECT @@TRANCOUNT', 'SCHEMA') == 0
45-
end
4642

4743
def supports_statement_cache?
4844
true
@@ -61,7 +57,7 @@ def rollback_db_transaction
6157
end
6258

6359
def create_savepoint
64-
disable_auto_reconnect { do_execute "SAVE TRANSACTION #{current_savepoint_name}" }
60+
# disable_auto_reconnect { do_execute "SAVE TRANSACTION #{current_savepoint_name}" }
6561
end
6662

6763
def release_savepoint

test/cases/transaction_test_sqlserver.rb

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,8 @@ class TransactionTestSqlserver < ActiveRecord::TestCase
3535
end
3636

3737
context 'Testing #outside_transaction?' do
38-
39-
should 'work in simple usage' do
40-
assert Ship.connection.outside_transaction?
41-
Ship.connection.begin_db_transaction
42-
assert !Ship.connection.outside_transaction?
43-
Ship.connection.rollback_db_transaction
44-
assert Ship.connection.outside_transaction?
45-
end
46-
47-
should 'work inside nested transactions' do
48-
assert Ship.connection.outside_transaction?
49-
Ship.transaction do
50-
assert !Ship.connection.outside_transaction?
51-
Ship.transaction do
52-
assert !Ship.connection.outside_transaction?
53-
end
54-
end
55-
assert Ship.connection.outside_transaction?
56-
end
38+
39+
5740

5841
should 'not call rollback if no transaction is active' do
5942
assert_raise RuntimeError do

0 commit comments

Comments
 (0)