active_record_host_pool 4.3.0 → 4.3.2

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: fced473565b601f6ec0a0e682b254c251d653c10be16690c46470d418dd9f346
4
- data.tar.gz: 7281ce45c44d5209f16444e55caaaf4c2a059981d6a41a48d45d0f394c08b4a3
3
+ metadata.gz: 48368e6adaec7dd24d0f49178678ddb5bfe5282e8802b72737c87615dbdfe7d2
4
+ data.tar.gz: 8a3a76bf1e65d5a7a0e1425359294b8b2aefba02250cc4b85ad97540db9613f1
5
5
  SHA512:
6
- metadata.gz: a053ec7e487686f9ab3aa0b5c01912292aee086f3d9e2444e715c99f9ef278c564b2a48b8eceb68030972c10ac20c04b20745689e88efdd9ae333256a033a371
7
- data.tar.gz: d6f6bc52d1e46987faf4b7d57b7e6df43464e60ed978b3337056957f3e8d5b98ed1fc38f156ea1766b7c299ee1094a68e3ec6a13e8741117e311cb23d54ce385
6
+ metadata.gz: 914e044d5ee7a21e090fd00a177fd3e8fb3d2588cc5941b20c7aeeb5e435cb7731da507e7138f349c7c14c057afc4ff6ed124b6b62bc8ecdbd540af2594a9af2
7
+ data.tar.gz: 37362e2dc2a4279598a700f061ca2206f53d1c0db79be8fa08ac1261a8ab7fab1f03f8f43919a270a016d130c8c517b8aae8ab56a74f8ba91fd940c46999f2d8
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
+ ## [4.3.2]
10
+
11
+ - Better compatibility with Rails 8.2 alpha.
12
+
13
+ ## [4.3.1]
14
+
15
+ - Better compatibility with Rails 8.2 alpha.
16
+
9
17
  ## [4.3.0]
10
18
 
11
19
  ### Changed
@@ -32,6 +32,17 @@ module ActiveRecordHostPool
32
32
  end
33
33
  end
34
34
 
35
+ # Rails 8.2 executes queries via QueryIntent -> execute_intent -> perform_query,
36
+ # bypassing with_raw_connection, so the switch must happen here instead. Raising
37
+ # from here (e.g. a lost connection during select_db) feeds into the intent's
38
+ # retry/reconnect machinery, matching the old with_raw_connection semantics.
39
+ if ActiveRecord.version >= Gem::Version.new("8.2.a")
40
+ def perform_query(raw_connection, intent)
41
+ _switch_connection(raw_connection) if _host_pool_desired_database && !_no_switch
42
+ super
43
+ end
44
+ end
45
+
35
46
  def drop_database(...)
36
47
  self._no_switch = true
37
48
  super
@@ -59,10 +70,10 @@ module ActiveRecordHostPool
59
70
  def _switch_connection(real_connection)
60
71
  if _host_pool_desired_database &&
61
72
  (
62
- _desired_database_changed? ||
63
- _real_connection_changed?
64
- )
65
- log(select_db_log_arg, "SQL") do
73
+ _desired_database_changed? ||
74
+ _real_connection_changed?
75
+ )
76
+ _log_select_db do
66
77
  clear_cache!
67
78
  real_connection.select_db(_host_pool_desired_database)
68
79
  end
@@ -71,13 +82,26 @@ module ActiveRecordHostPool
71
82
  end
72
83
  end
73
84
 
74
- if ActiveRecord.version < Gem::Version.new("8.2.a")
75
- def select_db_log_arg
76
- "select_db #{_host_pool_desired_database}"
85
+ if ActiveRecord.version >= Gem::Version.new("8.1")
86
+ def _log_select_db(&block)
87
+ instrumenter.instrument(
88
+ "sql.active_record",
89
+ sql: "select_db #{_host_pool_desired_database}",
90
+ name: "SQL",
91
+ binds: [],
92
+ type_casted_binds: [],
93
+ async: false,
94
+ allow_retry: false,
95
+ connection: self,
96
+ transaction: current_transaction.user_transaction.presence,
97
+ affected_rows: 0,
98
+ row_count: 0,
99
+ &block
100
+ )
77
101
  end
78
102
  else
79
- def select_db_log_arg
80
- ActiveRecord::ConnectionAdapters::QueryIntent.new(processed_sql: "select_db #{_host_pool_desired_database}")
103
+ def _log_select_db(&block)
104
+ log("select_db #{_host_pool_desired_database}", "SQL", &block)
81
105
  end
82
106
  end
83
107
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordHostPool
4
- VERSION = "4.3.0"
4
+ VERSION = "4.3.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: 4.3.0
4
+ version: 4.3.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: 2025-11-11 00:00:00.000000000 Z
14
+ date: 2026-08-27 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activerecord