replica_pools 2.3.1 → 2.4.1

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
  SHA256:
3
- metadata.gz: 1af9dd473884c12967be5648f4ff8e1cc2a029544bb27a76f7166698215b45f5
4
- data.tar.gz: be05c7e623ec0cae9b3d6841edb6a6e5de1ada29c79a5f11854fc98000e63f7e
3
+ metadata.gz: ab90e26beb7efb6b13dd59a067a1507207d657659cac075ee91d1364a652e476
4
+ data.tar.gz: 166edf9e559cc696d837f32c8558e31fc69e1b24708e4d6a543210317f7af5e2
5
5
  SHA512:
6
- metadata.gz: 99628a0df9823b14dae7a3dd2bd7d8ecb8e0333827616e06a56a352024fe27b89e6521af6a06e7dda243c92884aeb75437c8faad573c9598b7468e0fac1a87e3
7
- data.tar.gz: e2ea27e89f05990765bb7025508ed590030f86763a44066f4f4372ec4239a71718fa0267e87b1027b0d0fb4ef4282dee24d2d1ec594a51d593d24be93ea7552e
6
+ metadata.gz: bf7ec04c450f7338bb5aac3bb41784dd88b2d3e069423fc5fdfbe8f9d13657eb3e35180c5a52e18099a608effd6c57073c5b20af2150e2b20a6710a8eac4388b
7
+ data.tar.gz: 4dfb218fbf9136d536b218072c2bba6a06ccd2412403461b9bc19184e9ac1767b8d1af64b5c025532f08651dd3b2fb4d04beea3e6202ea0f901a856f2a8396db
@@ -42,7 +42,7 @@ module ReplicaPools
42
42
  select_values
43
43
  verify!
44
44
  ]
45
- elsif [5, 6].include?(ActiveRecord::VERSION::MAJOR)
45
+ elsif [5, 6, 7].include?(ActiveRecord::VERSION::MAJOR)
46
46
  %i[
47
47
  active?
48
48
  cacheable_query
@@ -34,11 +34,14 @@ module ReplicaPools
34
34
  end
35
35
 
36
36
  def config_hash
37
- if ActiveRecord::VERSION::MAJOR >= 6
38
- # in Rails >= 6, `configurations` is an instance of ActiveRecord::DatabaseConfigurations
37
+ if ActiveRecord::VERSION::MAJOR > 6
38
+ # in Rails = 7, ActiveRecord::Base.configurations.to_h has been deprecated
39
39
  ActiveRecord::Base.configurations.configs_for.map do |c|
40
40
  [c.env_name, c.configuration_hash.transform_keys(&:to_s)]
41
41
  end.to_h
42
+ elsif ActiveRecord::VERSION::MAJOR == 6
43
+ # in Rails = 6, `configurations` is an instance of ActiveRecord::DatabaseConfigurations
44
+ ActiveRecord::Base.configurations.to_h
42
45
  else
43
46
  # in Rails < 6, it's just a hash
44
47
  ActiveRecord::Base.configurations
@@ -19,11 +19,8 @@ module ReplicaPools
19
19
  # connection for cache logic, but ultimately pass its query
20
20
  # through to whatever connection is current.
21
21
  def select_all(*args)
22
- # there may be more args for Rails 5.0+, but we only care about arel, name, and binds for caching.
23
22
  relation, name, raw_binds = args
24
23
 
25
- # Rails 6.2 breaks this method as locked? is no longer available
26
- # https://github.com/kickstarter/replica_pools/issues/26
27
24
  if !query_cache_enabled || locked?(relation)
28
25
  return route_to(current, :select_all, *args)
29
26
  end
@@ -47,6 +44,14 @@ module ReplicaPools
47
44
  end
48
45
  end
49
46
 
47
+ # If arel is locked this is a SELECT ... FOR UPDATE or somesuch. Such
48
+ # queries should not be cached.
49
+ def locked?(arel)
50
+ # This method was copied from Rails 6.1, since it has been removed in 7.0
51
+ arel = arel.arel if arel.is_a?(ActiveRecord::Relation)
52
+ arel.respond_to?(:locked) && arel.locked
53
+ end
54
+
50
55
  # these can use the unsafe delegation built into ConnectionProxy
51
56
  # [:insert, :update, :delete]
52
57
  end
@@ -1,3 +1,3 @@
1
1
  module ReplicaPools
2
- VERSION = "2.3.1"
2
+ VERSION = "2.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: replica_pools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Drabik
@@ -9,22 +9,28 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-07-13 00:00:00.000000000 Z
12
+ date: 2023-02-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ">"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '6.0'
21
+ - - "<"
22
+ - !ruby/object:Gem::Version
23
+ version: '8.0'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
24
27
  requirements:
25
- - - "~>"
28
+ - - ">"
26
29
  - !ruby/object:Gem::Version
27
30
  version: '6.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '8.0'
28
34
  - !ruby/object:Gem::Dependency
29
35
  name: mysql2
30
36
  requirement: !ruby/object:Gem::Requirement