active_record_host_pool 2.0.0 → 2.2.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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc285794dcf2d9fd3d54249bc94aea1a9ae64d76868040dc583aa669388cd444
|
4
|
+
data.tar.gz: fe57775f7b80266bddb5f019b48eb7f5a741a7a9f8e0858604e6a74e12df5501
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76037970cdd4288865b5e7e02d233d64699c60cc9054887465b21442e136da7f336d77623be76222ee45a75daac74b5e34581942793bf379fcb7df0b6229a4c4
|
7
|
+
data.tar.gz: e8ae94a9a9141891e5a4dbb0a61d08b13499546603b409f73d9a0de799112c68ca2705670a200c08cbb7ce3178135040808ac14323ac223afbc9519e21bff960
|
data/Changelog.md
CHANGED
@@ -6,6 +6,27 @@ and as of v1.0.0 this project adheres to [Semantic Versioning](https://semver.or
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [2.2.0]
|
10
|
+
### Removed
|
11
|
+
- Support for Ruby 3.0.
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- Rails 6.1 testing with Trilogy.
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- Fixed using ActiveRecordHostPool and the `activerecord-trilogy-adapter v3.1+`.
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- ActiveRecordHostPool will now raise an exception if you try to use a version of `activerecord-trilogy-adapter < 3.1`.
|
21
|
+
|
22
|
+
## [2.1.0]
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
- 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.
|
26
|
+
|
27
|
+
### Removed
|
28
|
+
- Dropped support for Ruby 2.7.x.
|
29
|
+
|
9
30
|
## [2.0.0]
|
10
31
|
|
11
32
|
### Added
|
@@ -7,7 +7,6 @@ when :trilogy
|
|
7
7
|
case "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
|
8
8
|
when "6.1", "7.0"
|
9
9
|
require "trilogy_adapter/connection"
|
10
|
-
require "trilogy_adapter/errors"
|
11
10
|
ActiveRecord::Base.extend(TrilogyAdapter::Connection)
|
12
11
|
when "7.1"
|
13
12
|
require "active_record/connection_adapters/trilogy_adapter"
|
@@ -18,32 +17,7 @@ end
|
|
18
17
|
|
19
18
|
module ActiveRecordHostPool
|
20
19
|
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
|
-
|
20
|
+
attr_reader :_host_pool_current_database
|
47
21
|
def initialize(*)
|
48
22
|
@_cached_current_database = nil
|
49
23
|
super
|
@@ -54,44 +28,42 @@ module ActiveRecordHostPool
|
|
54
28
|
@config[:database] = _host_pool_current_database
|
55
29
|
end
|
56
30
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
if ActiveRecord.version >= Gem::Version.new("7.1")
|
62
|
-
ruby2_keywords def raw_execute_with_switching(*args)
|
31
|
+
if ActiveRecord.version >= Gem::Version.new("7.1") || ActiveRecordHostPool.loaded_db_adapter == :trilogy
|
32
|
+
# Patch `raw_execute` instead of `execute` since this commit:
|
33
|
+
# https://github.com/rails/rails/commit/f69bbcbc0752ca5d5af327d55922614a26f5c7e9
|
34
|
+
def raw_execute(...)
|
63
35
|
if _host_pool_current_database && !_no_switch
|
64
36
|
_switch_connection
|
65
37
|
end
|
66
|
-
|
38
|
+
super
|
67
39
|
end
|
68
40
|
else
|
69
|
-
|
41
|
+
def execute(...)
|
70
42
|
if _host_pool_current_database && !_no_switch
|
71
43
|
_switch_connection
|
72
44
|
end
|
73
|
-
|
45
|
+
super
|
74
46
|
end
|
75
47
|
end
|
76
48
|
|
77
|
-
def
|
49
|
+
def drop_database(...)
|
78
50
|
self._no_switch = true
|
79
|
-
|
51
|
+
super
|
80
52
|
ensure
|
81
53
|
self._no_switch = false
|
82
54
|
end
|
83
55
|
|
84
|
-
def
|
56
|
+
def create_database(...)
|
85
57
|
self._no_switch = true
|
86
|
-
|
58
|
+
super
|
87
59
|
ensure
|
88
60
|
self._no_switch = false
|
89
61
|
end
|
90
62
|
|
91
|
-
def
|
63
|
+
def disconnect!
|
92
64
|
@_cached_current_database = nil
|
93
65
|
@_cached_connection_object_id = nil
|
94
|
-
|
66
|
+
super
|
95
67
|
end
|
96
68
|
|
97
69
|
private
|
@@ -130,9 +102,9 @@ end
|
|
130
102
|
|
131
103
|
case ActiveRecordHostPool.loaded_db_adapter
|
132
104
|
when :mysql2
|
133
|
-
ActiveRecord::ConnectionAdapters::Mysql2Adapter.
|
105
|
+
ActiveRecord::ConnectionAdapters::Mysql2Adapter.prepend(ActiveRecordHostPool::DatabaseSwitch)
|
134
106
|
when :trilogy
|
135
|
-
ActiveRecord::ConnectionAdapters::TrilogyAdapter.
|
107
|
+
ActiveRecord::ConnectionAdapters::TrilogyAdapter.prepend(ActiveRecordHostPool::DatabaseSwitch)
|
136
108
|
end
|
137
109
|
|
138
110
|
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
|
@@ -15,7 +15,11 @@ if Gem.loaded_specs.include?("mysql2")
|
|
15
15
|
ActiveRecordHostPool.loaded_db_adapter = :mysql2
|
16
16
|
elsif Gem.loaded_specs.include?("trilogy")
|
17
17
|
require "trilogy"
|
18
|
-
|
18
|
+
if ActiveRecord.version < Gem::Version.new("7.1")
|
19
|
+
require "activerecord-trilogy-adapter"
|
20
|
+
require "trilogy_adapter/version"
|
21
|
+
raise "ActiveRecordHostPool is only compatible with activerecord-trilogy-adapter v3.1+" if Gem::Version.new("3.1") > TrilogyAdapter::VERSION
|
22
|
+
end
|
19
23
|
ActiveRecordHostPool.loaded_db_adapter = :trilogy
|
20
24
|
end
|
21
25
|
|
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.2.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-07-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activerecord
|
@@ -20,9 +20,6 @@ dependencies:
|
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 6.1.0
|
23
|
-
- - "<"
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: '7.2'
|
26
23
|
type: :runtime
|
27
24
|
prerelease: false
|
28
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,9 +27,6 @@ dependencies:
|
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 6.1.0
|
33
|
-
- - "<"
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '7.2'
|
36
30
|
description: ''
|
37
31
|
email:
|
38
32
|
- bquorning@zendesk.com
|
@@ -65,14 +59,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
59
|
requirements:
|
66
60
|
- - ">="
|
67
61
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
62
|
+
version: 3.1.0
|
69
63
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
64
|
requirements:
|
71
65
|
- - ">="
|
72
66
|
- !ruby/object:Gem::Version
|
73
67
|
version: '0'
|
74
68
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.5.11
|
76
70
|
signing_key:
|
77
71
|
specification_version: 4
|
78
72
|
summary: Allow ActiveRecord to share a connection to multiple databases on the same
|