active_record_proxy_adapters 0.10.2 → 0.11.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: 70250167498af840cadd4a35c83be8d093566e414c84c44b821c9d2e23dea3ca
4
- data.tar.gz: '093ec59b4123dc6b695eff81f124fca929619cc9ed33709b2167fb01863fa3fb'
3
+ metadata.gz: e9709c38149a112c5203c15ed59fe97903484dcc7842c82e070c57d29fea21ed
4
+ data.tar.gz: f9054fc5ce575e3d0877a4aa3b3ba9cd59da532c4b30d85536e4f63318119aee
5
5
  SHA512:
6
- metadata.gz: a782b3dea740b91f81c5f57a97cb9116343cbb990a41a80757d713e7893b5fa9d1565c730ed0eab8f55902a248551abcc5c8bfa6579ed51c3d5ae4d6e435eca5
7
- data.tar.gz: 9fa48c67ac8da9ee1f9e4b1bacff13847eec8d1b8c3956bc6de822096b343e1d4ac2a65740ecf3525682e0d380fa6f928e0cdcd6c7255d101fcb03912392ed5b
6
+ metadata.gz: 7fe2bf87693040205f3e1aa62cc48b783d830b618d65423a4a8c3bae1dc029aae526d00227f5ca7ed4542dba04832641a86b2344ab6036956d3b2d9d1fc90b6b
7
+ data.tar.gz: 26c32105d9ed2c6f6d49016224284077207f780d0d3e56e62a59e81441808b1c00109f52c0baf867b09dba1a33a7aab2e12e4bc54b59789ddf288f0802e615cd
@@ -17,9 +17,24 @@ module ActiveRecordProxyAdapters
17
17
  connection.connection_class || ActiveRecord::Base
18
18
  end
19
19
 
20
+ # rubocop:disable Style/TrailingCommaInArrayLiteral
20
21
  def hijackable_methods
21
- %i[exec_delete exec_insert exec_query exec_update execute select]
22
+ [
23
+ # Create
24
+ :insert,
25
+ :exec_insert_all, # this one is an exception to the rule. there's no higher-level equivalent method to be called
26
+ # Retrieve
27
+ :select,
28
+ # Update
29
+ :update,
30
+ # Delete
31
+ :delete,
32
+ # Generic
33
+ :exec_query,
34
+ :execute,
35
+ ]
22
36
  end
37
+ # rubocop:enable Style/TrailingCommaInArrayLiteral
23
38
 
24
39
  def active_record_v7?
25
40
  active_record_version >= Gem::Version.new("7.2") && active_record_version < Gem::Version.new("8.0")
@@ -102,7 +102,8 @@ module ActiveRecordProxyAdapters
102
102
  end
103
103
 
104
104
  def coerce_query_to_string(sql_or_arel)
105
- sql_or_arel.respond_to?(:to_sql) ? sql_or_arel.to_sql : sql_or_arel.to_s
105
+ # TODO: implement custom Proxy arel parser
106
+ sql_or_arel.respond_to?(:to_sql) ? sql_or_arel.to_sql(connection_class) : sql_or_arel.to_s
106
107
  end
107
108
 
108
109
  def appropriate_connection(sql_string, &block)
@@ -173,7 +174,14 @@ module ActiveRecordProxyAdapters
173
174
 
174
175
  result
175
176
  ensure
176
- replica_connection?(connection) && replica_pool.checkin(connection)
177
+ # Check the connection back into its own pool, not whatever pool currently
178
+ # answers to the :reading role. In Rails system tests,
179
+ # ActiveRecord::TestFixtures#setup_shared_connection_pool reassigns the
180
+ # :reading role's pool_config on every transactional-fixture test's
181
+ # before_setup, so re-resolving `replica_pool` here can return a pool
182
+ # different from the one the connection was checked out of — which would
183
+ # check a replica adapter into the primary pool and poison it.
184
+ connection.pool.checkin(connection) if replica_connection?(connection)
177
185
  end
178
186
 
179
187
  def connected_to(role:, &block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordProxyAdapters
4
- VERSION = "0.10.2"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_proxy_adapters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Cruz