active_record_host_pool 2.0.0 → 2.1.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba0aa0ff3c0b19e4895118e76f84cc57f46481baa482c59925946ecd56765bb
|
4
|
+
data.tar.gz: e276dbda95168a03b511a5d7da14f94411ca7b8bc910ea2684631f25c9a22cf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b455f5fd116f96035fa816b39e0baf7f698d885decece79fd213c690c07db6b2f54e2328d4fa8dab68c536e86b58a9261b3c1a4c8aa45ccf35c1cb7b237168e
|
7
|
+
data.tar.gz: aa7295a9be8e2892ff34452de014ea7627255d58e6eccd6a0d4a18d3b03152adb18fb2e453df017a058eeaf26bf8d4a768db3e436cef7da498f69e03d5f50917
|
data/Changelog.md
CHANGED
@@ -6,6 +6,14 @@ and as of v1.0.0 this project adheres to [Semantic Versioning](https://semver.or
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.1.0]
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- ActiveRecordHostPool now uses prepend to patch `#execute`, `#raw_execute`, `#drop_database`, `#create_database`, and `#disconnect!`. Prepending is incompatible when also using `alias` or `alias_method` to patch those methods; avoid aliasing them to prevent an infinite loop.
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
- Dropped support for Ruby 2.7.x.
|
16
|
+
|
9
17
|
## [2.0.0]
|
10
18
|
|
11
19
|
### Added
|
@@ -18,32 +18,7 @@ end
|
|
18
18
|
|
19
19
|
module ActiveRecordHostPool
|
20
20
|
module DatabaseSwitch
|
21
|
-
|
22
|
-
base.class_eval do
|
23
|
-
attr_reader(:_host_pool_current_database)
|
24
|
-
|
25
|
-
# Patch `raw_execute` instead of `execute` since this commit:
|
26
|
-
# https://github.com/rails/rails/commit/f69bbcbc0752ca5d5af327d55922614a26f5c7e9
|
27
|
-
case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
|
28
|
-
when "7.1"
|
29
|
-
alias_method :raw_execute_without_switching, :raw_execute
|
30
|
-
alias_method :raw_execute, :raw_execute_with_switching
|
31
|
-
else
|
32
|
-
alias_method :execute_without_switching, :execute
|
33
|
-
alias_method :execute, :execute_with_switching
|
34
|
-
end
|
35
|
-
|
36
|
-
alias_method :drop_database_without_no_switching, :drop_database
|
37
|
-
alias_method :drop_database, :drop_database_with_no_switching
|
38
|
-
|
39
|
-
alias_method :create_database_without_no_switching, :create_database
|
40
|
-
alias_method :create_database, :create_database_with_no_switching
|
41
|
-
|
42
|
-
alias_method :disconnect_without_host_pooling!, :disconnect!
|
43
|
-
alias_method :disconnect!, :disconnect_with_host_pooling!
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
21
|
+
attr_reader :_host_pool_current_database
|
47
22
|
def initialize(*)
|
48
23
|
@_cached_current_database = nil
|
49
24
|
super
|
@@ -54,44 +29,42 @@ module ActiveRecordHostPool
|
|
54
29
|
@config[:database] = _host_pool_current_database
|
55
30
|
end
|
56
31
|
|
57
|
-
def self.ruby2_keywords(*); end unless respond_to?(:ruby2_keywords, true)
|
58
|
-
# This one really does need ruby2_keywords; in Rails 6.0 the method does not take
|
59
|
-
# any keyword arguments, but in Rails 7.0+ it does. So, we don't know whether or not
|
60
|
-
# what we're delegating to takes kwargs, so ruby2_keywords is needed.
|
61
32
|
if ActiveRecord.version >= Gem::Version.new("7.1")
|
62
|
-
|
33
|
+
# Patch `raw_execute` instead of `execute` since this commit:
|
34
|
+
# https://github.com/rails/rails/commit/f69bbcbc0752ca5d5af327d55922614a26f5c7e9
|
35
|
+
def raw_execute(...)
|
63
36
|
if _host_pool_current_database && !_no_switch
|
64
37
|
_switch_connection
|
65
38
|
end
|
66
|
-
|
39
|
+
super
|
67
40
|
end
|
68
41
|
else
|
69
|
-
|
42
|
+
def execute(...)
|
70
43
|
if _host_pool_current_database && !_no_switch
|
71
44
|
_switch_connection
|
72
45
|
end
|
73
|
-
|
46
|
+
super
|
74
47
|
end
|
75
48
|
end
|
76
49
|
|
77
|
-
def
|
50
|
+
def drop_database(...)
|
78
51
|
self._no_switch = true
|
79
|
-
|
52
|
+
super
|
80
53
|
ensure
|
81
54
|
self._no_switch = false
|
82
55
|
end
|
83
56
|
|
84
|
-
def
|
57
|
+
def create_database(...)
|
85
58
|
self._no_switch = true
|
86
|
-
|
59
|
+
super
|
87
60
|
ensure
|
88
61
|
self._no_switch = false
|
89
62
|
end
|
90
63
|
|
91
|
-
def
|
64
|
+
def disconnect!
|
92
65
|
@_cached_current_database = nil
|
93
66
|
@_cached_connection_object_id = nil
|
94
|
-
|
67
|
+
super
|
95
68
|
end
|
96
69
|
|
97
70
|
private
|
@@ -130,9 +103,9 @@ end
|
|
130
103
|
|
131
104
|
case ActiveRecordHostPool.loaded_db_adapter
|
132
105
|
when :mysql2
|
133
|
-
ActiveRecord::ConnectionAdapters::Mysql2Adapter.
|
106
|
+
ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(ActiveRecordHostPool::DatabaseSwitch)
|
134
107
|
when :trilogy
|
135
|
-
ActiveRecord::ConnectionAdapters::TrilogyAdapter.
|
108
|
+
ActiveRecord::ConnectionAdapters::TrilogyAdapter.prepend(ActiveRecordHostPool::DatabaseSwitch)
|
136
109
|
end
|
137
110
|
|
138
111
|
ActiveRecord::ConnectionAdapters::PoolConfig.prepend(ActiveRecordHostPool::PoolConfigPatch)
|
@@ -44,14 +44,13 @@ module ActiveRecordHostPool
|
|
44
44
|
__getobj__.private_methods(all) | super
|
45
45
|
end
|
46
46
|
|
47
|
-
def send(symbol,
|
47
|
+
def send(symbol, ...)
|
48
48
|
if respond_to?(symbol, true) && !__getobj__.respond_to?(symbol, true)
|
49
49
|
super
|
50
50
|
else
|
51
|
-
__getobj__.send(symbol,
|
51
|
+
__getobj__.send(symbol, ...)
|
52
52
|
end
|
53
53
|
end
|
54
|
-
ruby2_keywords :send if respond_to?(:ruby2_keywords, true)
|
55
54
|
|
56
55
|
def ==(other)
|
57
56
|
self.class == other.class &&
|
@@ -67,9 +66,8 @@ module ActiveRecordHostPool
|
|
67
66
|
|
68
67
|
private
|
69
68
|
|
70
|
-
def select(
|
71
|
-
@cx.__send__(:select,
|
69
|
+
def select(...)
|
70
|
+
@cx.__send__(:select, ...)
|
72
71
|
end
|
73
|
-
ruby2_keywords :select if respond_to?(:ruby2_keywords, true)
|
74
72
|
end
|
75
73
|
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: 2.
|
4
|
+
version: 2.1.0
|
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: 2024-
|
14
|
+
date: 2024-04-19 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|
@@ -65,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.0.0
|
69
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
75
|
+
rubygems_version: 3.5.3
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Allow ActiveRecord to share a connection to multiple databases on the same
|