active_record_host_pool 1.2.1 → 1.2.2

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: 6c8a74e78b05f5094b89403c7e77ebbe40802ebeeec9f8ea724cdf3527c20dea
4
- data.tar.gz: 8e8e5c3ba32256bcf5c39e974bb8565ae464bad9aafa41d0ad5309802d226dc2
3
+ metadata.gz: 798f8b22ed7ed2801d40f3aaeb653ad4882ab3523daa1d93183b659adb5c3941
4
+ data.tar.gz: ccf81d17ac0e64a4b727b0aff13ac208514104c34e20536818fe4983efbde390
5
5
  SHA512:
6
- metadata.gz: d3c9ed0921dae7152f1de4e498edd761960b81038c8d46a32674949fe152d8dd2b9ad8a836322d8cabf6f05a3484e9297a535553dc8c888109958fdb00eacea9
7
- data.tar.gz: fcb8f19f314456e8dc293a6233650723da2f6bad8548fba12671827d12bd1c3842cb555d2b2ca413488cadf9099b8b491b01ef256279099a3a3a0473b4507701
6
+ metadata.gz: 656affbe8e6eccff5d653cdbe7f560e6b48738dabfdd67187deadd76b6f46b51aef3ce96bf0955a52e6e74718b3c7e1a8664f74d69ba9458a17f48c8f85eecd2
7
+ data.tar.gz: 37c92ee23f9c58320b6be0011c80de891d0d518b7cc0a5481e2f8028b4d804e399dbc67dcc30aa4b807673ea7033357d29ddccf519d9d6210f64bac47d0584e5
@@ -29,10 +29,10 @@ if ActiveRecord.version >= Gem::Version.new('6.0')
29
29
 
30
30
  def clear_on_handler(handler)
31
31
  handler.all_connection_pools.each do |pool|
32
- db_was = pool.connection.unproxied._host_pool_current_database
33
- pool.connection.clear_query_cache if pool.active_connection?
32
+ db_was = pool._unproxied_connection._host_pool_current_database
33
+ pool._unproxied_connection.clear_query_cache if pool.active_connection?
34
34
  ensure
35
- pool.connection.unproxied._host_pool_current_database = db_was
35
+ pool._unproxied_connection._host_pool_current_database = db_was
36
36
  end
37
37
  end
38
38
  end
@@ -8,11 +8,6 @@ module ActiveRecordHostPool
8
8
  base.class_eval do
9
9
  attr_reader(:_host_pool_current_database)
10
10
 
11
- def _host_pool_current_database=(database)
12
- @_host_pool_current_database = database
13
- @config[:database] = _host_pool_current_database
14
- end
15
-
16
11
  alias_method :execute_without_switching, :execute
17
12
  alias_method :execute, :execute_with_switching
18
13
 
@@ -32,6 +27,11 @@ module ActiveRecordHostPool
32
27
  super
33
28
  end
34
29
 
30
+ def _host_pool_current_database=(database)
31
+ @_host_pool_current_database = database
32
+ @config[:database] = _host_pool_current_database
33
+ end
34
+
35
35
  def self.ruby2_keywords(*); end unless respond_to?(:ruby2_keywords, true)
36
36
  ruby2_keywords def execute_with_switching(*args, **kwargs)
37
37
  if _host_pool_current_database && !_no_switch
@@ -34,13 +34,17 @@ module ActiveRecordHostPool
34
34
  attr_reader :pool_config
35
35
 
36
36
  def connection(*args)
37
- real_connection = _connection_pool.connection(*args)
37
+ real_connection = _unproxied_connection(*args)
38
38
  _connection_proxy_for(real_connection, @config[:database])
39
39
  rescue Mysql2::Error, ActiveRecord::NoDatabaseError
40
40
  _connection_pools.delete(_pool_key)
41
41
  Kernel.raise
42
42
  end
43
43
 
44
+ def _unproxied_connection(*args)
45
+ _connection_pool.connection(*args)
46
+ end
47
+
44
48
  # by the time we are patched into ActiveRecord, the current thread has already established
45
49
  # a connection. thus we need to patch both connection and checkout/checkin
46
50
  def checkout(*args, &block)
@@ -36,13 +36,17 @@ module ActiveRecordHostPool
36
36
  attr_reader :spec
37
37
 
38
38
  def connection(*args)
39
- real_connection = _connection_pool.connection(*args)
39
+ real_connection = _unproxied_connection(*args)
40
40
  _connection_proxy_for(real_connection, @config[:database])
41
41
  rescue Mysql2::Error, ActiveRecord::NoDatabaseError
42
42
  _connection_pools.delete(_pool_key)
43
43
  Kernel.raise
44
44
  end
45
45
 
46
+ def _unproxied_connection(*args)
47
+ _connection_pool.connection(*args)
48
+ end
49
+
46
50
  # by the time we are patched into ActiveRecord, the current thread has already established
47
51
  # a connection. thus we need to patch both connection and checkout/checkin
48
52
  def checkout(*args, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordHostPool
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_host_pool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Quorning
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-12-23 00:00:00.000000000 Z
14
+ date: 2023-01-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord