transaction_isolation_level 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bda34739fa7b6dfb410d613b18e7f325a685deab
4
- data.tar.gz: edcca2f46a2bec03ea09a78d5aeb899ab40d5a81
3
+ metadata.gz: c51e2c4cd964967053705462a744b8d77dcb8058
4
+ data.tar.gz: c03c90b9c167fc596c75df50e31ef7a4362b5859
5
5
  SHA512:
6
- metadata.gz: 356341c609d337aec229bb36aa0d2fa64178b80ff92a7ff0c21a02c05b135760ff81f19c270444f2bf1360f786739f7b8cd817d140ef93dac849087cd868d3b6
7
- data.tar.gz: 7a3940a59b352252cbc82984d8c2a35ddc7e541ad1b29c24c919ebec49df4eeab32145cad5a705d3d4702f5077ecf592f5c4efad06ddd7adc5bcdaf942865e0f
6
+ metadata.gz: a03d54c3ec7bf025923b33022a260139025d0302fd89f7131303f23cd6c38e29b6f4daa4669f416643767c003906ba45ed12846ba30f899df460f845f508b410
7
+ data.tar.gz: 4892314111be7920d5111c8b9d80a96af5685fbc8cfb66ab8bdbc70b2b7d0eda2901b66930cdb3efd4733f08fe60d1c12a472ecdeb47755f959cd100446aefe4
data/Gemfile CHANGED
@@ -10,6 +10,4 @@ gemspec
10
10
  # Git. Remember to move these dependencies to your gemspec before releasing
11
11
  # your gem to rubygems.org.
12
12
 
13
- # To use debugger
14
- # gem 'ruby-debug19', :require => 'ruby-debug'
15
- # gem 'ruby-debug'
13
+ gem 'activerecord', ENV['RAILS_VERSION']
@@ -13,6 +13,13 @@ module ActiveRecord
13
13
  # uses the ConnectionHandler#establish_connection method we override here to load our patches once
14
14
  # ActiveRecord::Base#establish_connection has loaded the class to patch.
15
15
  def establish_connection_with_isolation_level_adapter_patches(*args)
16
+ # need to explicitly trigger load of the adapter for 5.1 and above, as from that point on its
17
+ # required only in establish_connection, and we don't have a way to insert our patches halfway
18
+ # through that method.
19
+ if (ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR > 0) || ActiveRecord::VERSION::MAJOR > 5
20
+ ConnectionSpecification::Resolver.new(Base.configurations).spec(args.last)
21
+ end
22
+
16
23
  require 'transaction_isolation_level/adapter_patches'
17
24
  establish_connection_without_isolation_level_adapter_patches(*args)
18
25
  end
@@ -68,8 +68,23 @@ module ActiveRecord
68
68
  execute "BEGIN TRANSACTION #{transaction_isolation_level_sql(@transaction_isolation_level)}"
69
69
  end
70
70
 
71
+ # the postgresql adapter calls configure_connection part way through its #initialize. after that point, it sets
72
+ # @type_map. however, by calling execute, our overridden configure_connection will run a query, and this requires
73
+ # a type map, which needs to be the postgresql-specific type that #initialize would instantiate, not the default
74
+ # created by #type_map in the abstract adapter code. so we override that default to be the same as #initialize
75
+ # will make.
71
76
  def type_map
72
- @type_map ||= PostgreSQLAdapter::OID::TypeMap.new.tap {|type_map| initialize_type_map(type_map)}
77
+ return @type_map if instance_variable_defined?(:@type_map)
78
+ @type_map =
79
+ if PostgreSQLAdapter::OID.const_defined?(:TypeMap)
80
+ # 5.0 and below
81
+ PostgreSQLAdapter::OID::TypeMap.new
82
+ else
83
+ # 5.1 and above
84
+ Type::HashLookupTypeMap.new
85
+ end
86
+ initialize_type_map(type_map)
87
+ @type_map
73
88
  end
74
89
 
75
90
  def configure_connection
@@ -1,3 +1,3 @@
1
1
  module TransactionIsolationLevel
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/test_all.sh ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ for version in 4.2.10 5.0.6 5.1.4 5.2.0.beta2
6
+ do
7
+ RAILS_VERSION=$version bundle update activerecord
8
+ RAILS_ENV=postgresql bundle exec rake
9
+ done
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transaction_isolation_level
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.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: 2017-04-24 00:00:00.000000000 Z
11
+ date: 2018-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -69,6 +69,7 @@ files:
69
69
  - test/database.yml
70
70
  - test/test_helper.rb
71
71
  - test/transaction_isolation_level_test.rb
72
+ - test_all.sh
72
73
  - transaction_isolation_level.gemspec
73
74
  homepage: http://github.com/willbryant/transaction_isolation_level
74
75
  licenses: []
@@ -89,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
90
  version: '0'
90
91
  requirements: []
91
92
  rubyforge_project:
92
- rubygems_version: 2.5.2
93
+ rubygems_version: 2.5.2.2
93
94
  signing_key:
94
95
  specification_version: 4
95
96
  summary: 'Adds :isolation_level option to ActiveRecord #transaction calls'