transaction_isolation_level 0.1.1 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b27af343f757f118df8665fe6941af39a8ca62b
4
- data.tar.gz: 2aab8e26736bf674148e4ceb0f40a4b7b134c125
3
+ metadata.gz: bda34739fa7b6dfb410d613b18e7f325a685deab
4
+ data.tar.gz: edcca2f46a2bec03ea09a78d5aeb899ab40d5a81
5
5
  SHA512:
6
- metadata.gz: 6d0720b6631dc8b7e78eada7b63f51f74ffd45d698dbb30c67cb0a1685085112ad81307d27c9f7c6ab57e889297038f5dad4ca0b39214625935fb35432c0b169
7
- data.tar.gz: 47e422f0bef7578f9693fd746404cf55a1d920deb2614973b4bd25b2124f6261c44835d3f794b3543e93d4abbba21c31b54b6ffd72b795dbc8ed30b1d0808926
6
+ metadata.gz: 356341c609d337aec229bb36aa0d2fa64178b80ff92a7ff0c21a02c05b135760ff81f19c270444f2bf1360f786739f7b8cd817d140ef93dac849087cd868d3b6
7
+ data.tar.gz: 7a3940a59b352252cbc82984d8c2a35ddc7e541ad1b29c24c919ebec49df4eeab32145cad5a705d3d4702f5077ecf592f5c4efad06ddd7adc5bcdaf942865e0f
@@ -43,7 +43,8 @@ module ActiveRecord
43
43
  transaction_without_isolation_level(options) { yield }
44
44
  end
45
45
 
46
- alias_method_chain :transaction, :isolation_level
46
+ alias :transaction_without_isolation_level :transaction
47
+ alias :transaction :transaction_with_isolation_level
47
48
  end
48
49
 
49
50
  class AbstractAdapter
@@ -62,7 +63,7 @@ module ActiveRecord
62
63
  end
63
64
  end
64
65
 
65
- PostgreSQLAdapter.class_eval do
66
+ module PostgreSQLAdapterPatches
66
67
  def begin_db_transaction
67
68
  execute "BEGIN TRANSACTION #{transaction_isolation_level_sql(@transaction_isolation_level)}"
68
69
  end
@@ -71,8 +72,8 @@ module ActiveRecord
71
72
  @type_map ||= PostgreSQLAdapter::OID::TypeMap.new.tap {|type_map| initialize_type_map(type_map)}
72
73
  end
73
74
 
74
- def configure_connection_with_isolation_level
75
- configure_connection_without_isolation_level
75
+ def configure_connection
76
+ super
76
77
  if @config[:transaction_isolation_level]
77
78
  @default_transaction_isolation_level = @config[:transaction_isolation_level].to_sym
78
79
  execute "SET SESSION CHARACTERISTICS AS TRANSACTION #{transaction_isolation_level_sql default_transaction_isolation_level}"
@@ -80,23 +81,16 @@ module ActiveRecord
80
81
  @default_transaction_isolation_level = transaction_isolation_level_from_sql(select_value("SELECT current_setting('default_transaction_isolation')"))
81
82
  end
82
83
  end
83
-
84
- alias_method_chain :configure_connection, :isolation_level
85
- end if const_defined?(:PostgreSQLAdapter)
84
+ end
86
85
 
87
86
  module MysqlAdapterPatches
88
- def self.included(base)
89
- base.alias_method_chain :begin_db_transaction, :isolation_level
90
- base.alias_method_chain :configure_connection, :isolation_level
91
- end
92
-
93
- def begin_db_transaction_with_isolation_level
87
+ def begin_db_transaction
94
88
  execute "SET TRANSACTION #{transaction_isolation_level_sql(@transaction_isolation_level)}" if @transaction_isolation_level # applies only to the next transaction
95
- begin_db_transaction_without_isolation_level
89
+ super
96
90
  end
97
91
 
98
- def configure_connection_with_isolation_level
99
- configure_connection_without_isolation_level
92
+ def configure_connection
93
+ super
100
94
  if @config[:transaction_isolation_level]
101
95
  @default_transaction_isolation_level = @config[:transaction_isolation_level].to_sym
102
96
  execute "SET SESSION TRANSACTION #{transaction_isolation_level_sql default_transaction_isolation_level}"
@@ -106,12 +100,16 @@ module ActiveRecord
106
100
  end
107
101
  end
108
102
 
103
+ PostgreSQLAdapter.class_eval do
104
+ prepend PostgreSQLAdapterPatches
105
+ end if const_defined?(:PostgreSQLAdapter)
106
+
109
107
  MysqlAdapter.class_eval do
110
- include MysqlAdapterPatches
108
+ prepend MysqlAdapterPatches
111
109
  end if const_defined?(:MysqlAdapter)
112
110
 
113
111
  Mysql2Adapter.class_eval do
114
- include MysqlAdapterPatches
112
+ prepend MysqlAdapterPatches
115
113
  end if const_defined?(:Mysql2Adapter)
116
114
  end
117
115
  end
@@ -1,3 +1,3 @@
1
1
  module TransactionIsolationLevel
2
- VERSION = '0.1.1'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transaction_isolation_level
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Bryant
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-02 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pg
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: 'Adds :isolation_level option to ActiveRecord #transaction calls, as
@@ -59,7 +59,7 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - .gitignore
62
+ - ".gitignore"
63
63
  - Gemfile
64
64
  - MIT-LICENSE
65
65
  - Rakefile
@@ -79,17 +79,17 @@ require_paths:
79
79
  - lib
80
80
  required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.0.14
92
+ rubygems_version: 2.5.2
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: 'Adds :isolation_level option to ActiveRecord #transaction calls'