active_record_proxy_adapters 0.10.2 → 0.11.1
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: 8af46e249283bd304b76cd6f92c4ebd8547078c29529e63a39c04c90ace297d2
|
|
4
|
+
data.tar.gz: c3753aaf59899dd7f97b288b4ead7f478a9341a32afba0e4603125e860956ad9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34eebec75d208cf8cc8226382dfe26b7e63e88e0e5c4ebbc802259875c0972b51346aabdf92c82ef912bcef92ba06933a54ccfa30060e31d69d2791e8bcb4fa6
|
|
7
|
+
data.tar.gz: e07490e7946807c07d626c43932ea1996349048ee953a1a407d7048c382446eb984530db358ff916d8c46f5548828a8325271399b92b4ac9a4db7ea563bae287
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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)
|
|
@@ -172,8 +173,6 @@ module ActiveRecordProxyAdapters
|
|
|
172
173
|
update_primary_latest_write_timestamp if !replica_connection?(connection) && write_statement?(sql_string)
|
|
173
174
|
|
|
174
175
|
result
|
|
175
|
-
ensure
|
|
176
|
-
replica_connection?(connection) && replica_pool.checkin(connection)
|
|
177
176
|
end
|
|
178
177
|
|
|
179
178
|
def connected_to(role:, &block)
|
|
@@ -187,7 +186,7 @@ module ActiveRecordProxyAdapters
|
|
|
187
186
|
end
|
|
188
187
|
|
|
189
188
|
def checkout_replica_connection
|
|
190
|
-
replica_pool.
|
|
189
|
+
replica_pool.lease_connection
|
|
191
190
|
# rescue NoDatabaseError to avoid crashing when running db:create rake task
|
|
192
191
|
# rescue ConnectionNotEstablished to handle connectivity issues in the replica
|
|
193
192
|
# (for example, replication delay)
|