sequel-activerecord_connection 1.2.11 → 1.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +14 -2
- data/lib/sequel/extensions/activerecord_connection.rb +17 -0
- data/sequel-activerecord_connection.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57e9f74b5adc96221191cb92f1be8b2e2614d2fce446bb43d50fc603e755c3d7
|
|
4
|
+
data.tar.gz: efdb083362ed82dec77628b75161aa913e2ef805a8b3d8bec621aaa2e1a693f7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0bf43086bf259333fb61dde411660ea2ba65bb03c2d98e123d63283dff257b970426ffb8494d5cc5b1f1d9c4cc73f6c65140c66e7346e8346d82adb7b20598c2
|
|
7
|
+
data.tar.gz: 83b368227d5620985878b5bdb1bc6a31ceb6a9b3f2c0b87b206126e5dcdbb05bb8a7e6917457f7bb04b37a22abac3c2ba9b6e8468bb4cf3eb27d4011ab17aa3e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -239,13 +239,25 @@ sensitive data from being stored in the logs, you can use the
|
|
|
239
239
|
logged SQL queries:
|
|
240
240
|
|
|
241
241
|
```rb
|
|
242
|
-
|
|
243
|
-
DB.extension :sql_log_normalizer
|
|
242
|
+
Sequel.postgres(extensions: [:activerecord_connection, :sql_log_normalizer])
|
|
244
243
|
```
|
|
245
244
|
```sql
|
|
246
245
|
SELECT accounts.* FROM accounts WHERE accounts.email = ? LIMIT ?
|
|
247
246
|
```
|
|
248
247
|
|
|
248
|
+
Note that the `sql_log_normalizer` extension opens a database connection while
|
|
249
|
+
it's being loaded. If you're setting up Sequel in a Rails initializer, you'll
|
|
250
|
+
probably want to handle the database not existing, so that commands such as
|
|
251
|
+
`rails db:create` continue to work.
|
|
252
|
+
|
|
253
|
+
```rb
|
|
254
|
+
DB = Sequel.postgres(extensions: :activerecord_connection)
|
|
255
|
+
begin
|
|
256
|
+
DB.extension :sql_log_normalizer
|
|
257
|
+
rescue ActiveRecord::NoDatabaseError
|
|
258
|
+
end
|
|
259
|
+
```
|
|
260
|
+
|
|
249
261
|
## Tests
|
|
250
262
|
|
|
251
263
|
You'll first want to run the rake tasks for setting up databases and users:
|
|
@@ -57,6 +57,13 @@ module Sequel
|
|
|
57
57
|
@timezone || activerecord_timezone
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
# Clear Active Record's query cache after potential data modifications.
|
|
61
|
+
def execute(*)
|
|
62
|
+
super
|
|
63
|
+
ensure
|
|
64
|
+
clear_activerecord_query_cache
|
|
65
|
+
end
|
|
66
|
+
|
|
60
67
|
private
|
|
61
68
|
|
|
62
69
|
# Synchronizes transaction state with ActiveRecord. Sequel uses this
|
|
@@ -136,6 +143,16 @@ module Sequel
|
|
|
136
143
|
super
|
|
137
144
|
end
|
|
138
145
|
|
|
146
|
+
if ActiveRecord.version >= Gem::Version.new("7.0")
|
|
147
|
+
def clear_activerecord_query_cache
|
|
148
|
+
activerecord_model.clear_query_caches_for_current_thread
|
|
149
|
+
end
|
|
150
|
+
else
|
|
151
|
+
def clear_activerecord_query_cache
|
|
152
|
+
activerecord_connection.clear_query_cache
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
139
156
|
# Active Record doesn't guarantee that a single connection can only be used
|
|
140
157
|
# by one thread at a time, so we need to use locking, which is what Active
|
|
141
158
|
# Record does internally as well.
|
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.3.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: 2023-
|
|
11
|
+
date: 2023-04-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sequel
|
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
139
|
version: '0'
|
|
140
140
|
requirements: []
|
|
141
|
-
rubygems_version: 3.4.
|
|
141
|
+
rubygems_version: 3.4.12
|
|
142
142
|
signing_key:
|
|
143
143
|
specification_version: 4
|
|
144
144
|
summary: Allows Sequel to use ActiveRecord connection for database interaction.
|