Skip to content

Commit c45f7c4

Browse files
authored
Fix for checking if raw connection transaction open (#1296)
1 parent b26d642 commit c45f7c4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/cases/coerced_tests.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,10 +2805,11 @@ def test_with_recursive_coerced
28052805

28062806
module ActiveRecord
28072807
class AdapterConnectionTest < ActiveRecord::TestCase
2808-
# Original method defined for core adapters.
2808+
# Original method only handled the core adapters.
28092809
undef_method :raw_transaction_open?
28102810
def raw_transaction_open?(connection)
2811-
connection.instance_variable_get(:@raw_connection).query("SELECT @@trancount").to_a[0][0] > 0
2811+
transaction_count = connection.instance_variable_get(:@raw_connection).execute("SELECT @@TRANCOUNT AS TRANSACTION_COUNT").first["TRANSACTION_COUNT"]
2812+
transaction_count > 0
28122813
rescue
28132814
false
28142815
end

0 commit comments

Comments
 (0)