sequel-activerecord_connection 1.4.3 → 1.5.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: ecd95c01a950e81d89914199827c09d3ef0b95b106cfe0601afa9dd40f395f62
|
4
|
+
data.tar.gz: 9f5c69f4291dfd46a1d07476a1fca226aafcdd6e6ef5c0ce697554a3c2d385e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85877ab167fbca19e25b366c05f934488f610f23b790cdd360c80e67cf0cecce35104846807f77374671d6e8214008c5aaab88f5ce10d47106060e049dc94f59
|
7
|
+
data.tar.gz: d25ed24c5444c0c6cdfeb91857b42db90f8d3115f1ca678b4e7ec876845255d65737e8e5d2837c633058356ad7ac32ab5da71085c68c5021134765a19a10b7ee
|
data/CHANGELOG.md
CHANGED
@@ -25,10 +25,12 @@ module Sequel
|
|
25
25
|
fail Error, "#{key.inspect} transaction option is currently not supported" if opts.key?(key)
|
26
26
|
end
|
27
27
|
|
28
|
-
super
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
super do |conn|
|
29
|
+
yield conn
|
30
|
+
rescue => e
|
31
|
+
activerecord_connection.clear_cache! if e.class.name == "ActiveRecord::PreparedStatementCacheExpired"
|
32
|
+
raise
|
33
|
+
end
|
32
34
|
end
|
33
35
|
|
34
36
|
private
|
@@ -39,7 +39,7 @@ module Sequel
|
|
39
39
|
|
40
40
|
# Avoid calling Sequel's connection pool, instead use Active Record's.
|
41
41
|
def synchronize(*)
|
42
|
-
|
42
|
+
activerecord_synchronize do
|
43
43
|
conn = activerecord_connection.raw_connection
|
44
44
|
|
45
45
|
if activerecord_connection_class && !conn.is_a?(activerecord_connection_class)
|
@@ -47,9 +47,9 @@ module Sequel
|
|
47
47
|
end
|
48
48
|
|
49
49
|
yield conn
|
50
|
+
ensure
|
51
|
+
clear_activerecord_query_cache
|
50
52
|
end
|
51
|
-
ensure
|
52
|
-
clear_activerecord_query_cache
|
53
53
|
end
|
54
54
|
|
55
55
|
# Log executed queries into Active Record logger as well.
|
@@ -140,7 +140,7 @@ module Sequel
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
if ActiveRecord.version >= Gem::Version.new("7.2
|
143
|
+
if ActiveRecord.version >= Gem::Version.new("7.2")
|
144
144
|
def activerecord_transaction_callback(type, &block)
|
145
145
|
activerecord_connection.current_transaction.public_send(type, &block)
|
146
146
|
end
|
@@ -158,6 +158,14 @@ module Sequel
|
|
158
158
|
super
|
159
159
|
end
|
160
160
|
|
161
|
+
def activerecord_synchronize
|
162
|
+
with_activerecord_connection do
|
163
|
+
activerecord_lock do
|
164
|
+
yield
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
161
169
|
if ActiveRecord.version >= Gem::Version.new("7.0")
|
162
170
|
def clear_activerecord_query_cache
|
163
171
|
activerecord_model.clear_query_caches_for_current_thread
|
@@ -168,10 +176,22 @@ module Sequel
|
|
168
176
|
end
|
169
177
|
end
|
170
178
|
|
179
|
+
if ActiveRecord.version >= Gem::Version.new("7.2")
|
180
|
+
def with_activerecord_connection
|
181
|
+
activerecord_model.with_connection(prevent_permanent_checkout: true) do
|
182
|
+
yield activerecord_connection
|
183
|
+
end
|
184
|
+
end
|
185
|
+
else
|
186
|
+
def with_activerecord_connection
|
187
|
+
yield activerecord_connection
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
171
191
|
# Active Record doesn't guarantee that a single connection can only be used
|
172
192
|
# by one thread at a time, so we need to use locking, which is what Active
|
173
193
|
# Record does internally as well.
|
174
|
-
if ActiveRecord.version >= Gem::Version.new("5.1
|
194
|
+
if ActiveRecord.version >= Gem::Version.new("5.1")
|
175
195
|
def activerecord_lock
|
176
196
|
activerecord_connection.lock.synchronize do
|
177
197
|
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel-activerecord_connection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|