transaction_isolation 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/README.md +4 -1
- data/lib/transaction_isolation/active_record/connection_adapters/mysql2_adapter.rb +1 -1
- data/lib/transaction_isolation/active_record/connection_adapters/postgresql_adapter.rb +1 -1
- data/lib/transaction_isolation/active_record/connection_adapters/sqlite3_adapter.rb +3 -3
- data/lib/transaction_isolation/version.rb +1 -1
- data/test/integration/active_record/base/isolation_level_test.rb +3 -3
- data/test/integration/active_record/connection_adapters/any_adapter/current_isolation_level_test.rb +4 -4
- data/test/integration/active_record/connection_adapters/any_adapter/current_vendor_isolation_level_test.rb +4 -4
- data/test/integration/active_record/connection_adapters/any_adapter/isolation_level_test.rb +4 -4
- data/test/integration/active_record/connection_adapters/any_adapter/supports_isolation_levels_test.rb +4 -4
- data/test/integration/active_record/connection_adapters/any_adapter/translate_exception_test.rb +4 -4
- data/test/library_setup.rb +1 -1
- metadata +35 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 490188a65b8c7c813af7d49c2c08857de92b8b43ad96c7447d44fc3461cf47f2
|
4
|
+
data.tar.gz: 914759a4c9c907acc153604fe16914578126dd69d7e9561695132e398ae820b0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d76fb1ad1dc822e9ff9630d507a9782efa03314804ad0385325c10fbe35d332b3d2cd80702ca83ecc3914a37a96e441495e80cbdb50f68986e8d26da1fdca984
|
7
|
+
data.tar.gz: b68c311d6f3d4ee712ed076eedd483d1a54d912029a5c9912b3fc815f1d235ffdad6967b9fa12a3fda04371d11637daf7af8430e632f42a72d352c90baad569b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,9 @@ Set transaction isolation level in the ActiveRecord in a database agnostic way.
|
|
4
4
|
Works with MySQL, PostgreSQL and SQLite as long as you are using new adapters mysql2, pg or sqlite3.
|
5
5
|
Supports all ANSI SQL isolation levels: :serializable, :repeatable_read, :read_committed, :read_uncommitted.
|
6
6
|
|
7
|
+
See also [transaction_retry](https://github.com/qertoip/transaction_retry) gem for auto-retrying transactions
|
8
|
+
on deadlocks and serialization errors.
|
9
|
+
|
7
10
|
## Example
|
8
11
|
|
9
12
|
ActiveRecord::Base.isolation_level( :serializable ) do
|
@@ -68,7 +71,7 @@ The highest level of transaction isolation is called "serializable" and that's w
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
71
|
-
rescue ActiveRecord::
|
74
|
+
rescue ActiveRecord::TransactionIsolationConflict => e
|
72
75
|
logger.warn( e.message )
|
73
76
|
retry
|
74
77
|
end
|
@@ -54,7 +54,7 @@ if defined?( ActiveRecord::ConnectionAdapters::Mysql2Adapter )
|
|
54
54
|
|
55
55
|
def translate_exception_with_transaction_isolation_conflict( exception, message )
|
56
56
|
if isolation_conflict?( exception )
|
57
|
-
::ActiveRecord::TransactionIsolationConflict.new( "Transaction isolation conflict detected: #{exception.message}"
|
57
|
+
::ActiveRecord::TransactionIsolationConflict.new( "Transaction isolation conflict detected: #{exception.message}" )
|
58
58
|
else
|
59
59
|
translate_exception_without_transaction_isolation_conflict( exception, message )
|
60
60
|
end
|
@@ -54,7 +54,7 @@ if defined?( ActiveRecord::ConnectionAdapters::PostgreSQLAdapter )
|
|
54
54
|
|
55
55
|
def translate_exception_with_transaction_isolation_conflict( exception, message )
|
56
56
|
if isolation_conflict?( exception )
|
57
|
-
::ActiveRecord::TransactionIsolationConflict.new( "Transaction isolation conflict detected: #{exception.message}"
|
57
|
+
::ActiveRecord::TransactionIsolationConflict.new( "Transaction isolation conflict detected: #{exception.message}" )
|
58
58
|
else
|
59
59
|
translate_exception_without_transaction_isolation_conflict( exception, message )
|
60
60
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
if defined?( ActiveRecord::ConnectionAdapters::
|
1
|
+
if defined?( ActiveRecord::ConnectionAdapters::SQLite3Adapter )
|
2
2
|
|
3
3
|
module TransactionIsolation
|
4
4
|
module ActiveRecord
|
@@ -52,7 +52,7 @@ if defined?( ActiveRecord::ConnectionAdapters::SQLiteAdapter )
|
|
52
52
|
|
53
53
|
def translate_exception_with_transaction_isolation_conflict( exception, message )
|
54
54
|
if isolation_conflict?( exception )
|
55
|
-
::ActiveRecord::TransactionIsolationConflict.new( "Transaction isolation conflict detected: #{exception.message}"
|
55
|
+
::ActiveRecord::TransactionIsolationConflict.new( "Transaction isolation conflict detected: #{exception.message}" )
|
56
56
|
else
|
57
57
|
translate_exception_without_transaction_isolation_conflict( exception, message )
|
58
58
|
end
|
@@ -73,4 +73,4 @@ if defined?( ActiveRecord::ConnectionAdapters::SQLiteAdapter )
|
|
73
73
|
|
74
74
|
ActiveRecord::ConnectionAdapters::SQLite3Adapter.send( :include, TransactionIsolation::ActiveRecord::ConnectionAdapters::SQLite3Adapter )
|
75
75
|
|
76
|
-
end
|
76
|
+
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ActiveRecordTest <
|
5
|
+
class ActiveRecordTest < Minitest::Test
|
6
6
|
|
7
|
-
class BaseTest <
|
7
|
+
class BaseTest < Minitest::Test
|
8
8
|
|
9
|
-
class IsolationLevelTest <
|
9
|
+
class IsolationLevelTest < Minitest::Test
|
10
10
|
|
11
11
|
def test_wraps_connection_isolation_level
|
12
12
|
ActiveRecord::Base.isolation_level( :serializable ) do
|
data/test/integration/active_record/connection_adapters/any_adapter/current_isolation_level_test.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ActiveRecordTest <
|
5
|
+
class ActiveRecordTest < Minitest::Test
|
6
6
|
|
7
|
-
class ConnectionAdaptersTest <
|
7
|
+
class ConnectionAdaptersTest < Minitest::Test
|
8
8
|
|
9
|
-
class AnyAdapterTest <
|
9
|
+
class AnyAdapterTest < Minitest::Test
|
10
10
|
|
11
|
-
class CurrentIsolationLevelTest <
|
11
|
+
class CurrentIsolationLevelTest < Minitest::Test
|
12
12
|
|
13
13
|
def test_returns_correct_default_isolation_level
|
14
14
|
if defined?( ActiveRecord::ConnectionAdapters::Mysql2Adapter )
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ActiveRecordTest <
|
5
|
+
class ActiveRecordTest < Minitest::Test
|
6
6
|
|
7
|
-
class ConnectionAdaptersTest <
|
7
|
+
class ConnectionAdaptersTest < Minitest::Test
|
8
8
|
|
9
|
-
class AnyAdapterTest <
|
9
|
+
class AnyAdapterTest < Minitest::Test
|
10
10
|
|
11
|
-
class CurrentVendorIsolationLevelTest <
|
11
|
+
class CurrentVendorIsolationLevelTest < Minitest::Test
|
12
12
|
|
13
13
|
def test_returns_correct_default_vendor_isolation_level
|
14
14
|
if defined?( ActiveRecord::ConnectionAdapters::Mysql2Adapter )
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ActiveRecordTest <
|
5
|
+
class ActiveRecordTest < Minitest::Test
|
6
6
|
|
7
|
-
class ConnectionAdaptersTest <
|
7
|
+
class ConnectionAdaptersTest < Minitest::Test
|
8
8
|
|
9
|
-
class AnyAdapterTest <
|
9
|
+
class AnyAdapterTest < Minitest::Test
|
10
10
|
|
11
|
-
class IsolationLevelTest <
|
11
|
+
class IsolationLevelTest < Minitest::Test
|
12
12
|
|
13
13
|
def test_without_a_block
|
14
14
|
original_isolation_level = ActiveRecord::Base.connection.current_isolation_level
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ActiveRecordTest <
|
5
|
+
class ActiveRecordTest < Minitest::Test
|
6
6
|
|
7
|
-
class ConnectionAdaptersTest <
|
7
|
+
class ConnectionAdaptersTest < Minitest::Test
|
8
8
|
|
9
|
-
class AnyAdapterTest <
|
9
|
+
class AnyAdapterTest < Minitest::Test
|
10
10
|
|
11
|
-
class SupportsIsolationLevelsTest <
|
11
|
+
class SupportsIsolationLevelsTest < Minitest::Test
|
12
12
|
|
13
13
|
def test_returns_true
|
14
14
|
assert( ActiveRecord::Base.connection.supports_isolation_levels? )
|
data/test/integration/active_record/connection_adapters/any_adapter/translate_exception_test.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
class ActiveRecordTest <
|
5
|
+
class ActiveRecordTest < Minitest::Test
|
6
6
|
|
7
|
-
class ConnectionAdaptersTest <
|
7
|
+
class ConnectionAdaptersTest < Minitest::Test
|
8
8
|
|
9
|
-
class AnyAdapterTest <
|
9
|
+
class AnyAdapterTest < Minitest::Test
|
10
10
|
|
11
|
-
class TranslateExceptionTest <
|
11
|
+
class TranslateExceptionTest < Minitest::Test
|
12
12
|
|
13
13
|
def test_does_not_break_existing_translation
|
14
14
|
assert_raises( ActiveRecord::StatementInvalid ) do
|
data/test/library_setup.rb
CHANGED
metadata
CHANGED
@@ -1,42 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transaction_isolation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Piotr 'Qertoip' Włodarek
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2018-06-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activerecord
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.0.11
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
:read_uncommitted.
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.11
|
27
|
+
description: |-
|
28
|
+
Set transaction isolation level in the ActiveRecord in a database agnostic way.
|
29
|
+
Works with MySQL, PostgreSQL and SQLite as long as you are using new adapters mysql2, pg or sqlite3.
|
30
|
+
Supports all ANSI SQL isolation levels: :serializable, :repeatable_read, :read_committed, :read_uncommitted.
|
33
31
|
email:
|
34
32
|
- qertoip@gmail.com
|
35
33
|
executables: []
|
36
34
|
extensions: []
|
37
35
|
extra_rdoc_files: []
|
38
36
|
files:
|
39
|
-
- .gitignore
|
37
|
+
- ".gitignore"
|
40
38
|
- Gemfile
|
41
39
|
- LICENSE
|
42
40
|
- README.md
|
@@ -69,27 +67,41 @@ files:
|
|
69
67
|
- transaction_isolation.gemspec
|
70
68
|
homepage: https://github.com/qertoip/transaction_isolation
|
71
69
|
licenses: []
|
70
|
+
metadata: {}
|
72
71
|
post_install_message:
|
73
72
|
rdoc_options: []
|
74
73
|
require_paths:
|
75
74
|
- lib
|
76
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
76
|
requirements:
|
79
|
-
- -
|
77
|
+
- - ">="
|
80
78
|
- !ruby/object:Gem::Version
|
81
79
|
version: 1.9.2
|
82
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
81
|
requirements:
|
85
|
-
- -
|
82
|
+
- - ">="
|
86
83
|
- !ruby/object:Gem::Version
|
87
84
|
version: '0'
|
88
85
|
requirements: []
|
89
86
|
rubyforge_project:
|
90
|
-
rubygems_version:
|
87
|
+
rubygems_version: 2.7.6
|
91
88
|
signing_key:
|
92
|
-
specification_version:
|
89
|
+
specification_version: 4
|
93
90
|
summary: Set transaction isolation level in the ActiveRecord in a database agnostic
|
94
91
|
way.
|
95
|
-
test_files:
|
92
|
+
test_files:
|
93
|
+
- test/db/all.rb
|
94
|
+
- test/db/db.rb
|
95
|
+
- test/db/migrations.rb
|
96
|
+
- test/db/queued_job.rb
|
97
|
+
- test/integration/active_record/base/isolation_level_test.rb
|
98
|
+
- test/integration/active_record/connection_adapters/any_adapter/current_isolation_level_test.rb
|
99
|
+
- test/integration/active_record/connection_adapters/any_adapter/current_vendor_isolation_level_test.rb
|
100
|
+
- test/integration/active_record/connection_adapters/any_adapter/isolation_level_test.rb
|
101
|
+
- test/integration/active_record/connection_adapters/any_adapter/supports_isolation_levels_test.rb
|
102
|
+
- test/integration/active_record/connection_adapters/any_adapter/translate_exception_test.rb
|
103
|
+
- test/library_setup.rb
|
104
|
+
- test/log/.gitkeep
|
105
|
+
- test/test_console.rb
|
106
|
+
- test/test_helper.rb
|
107
|
+
- test/test_runner.rb
|