sequel-activerecord_connection 1.5.1 → 2.0.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +11 -21
- data/lib/sequel/extensions/activerecord_connection.rb +12 -15
- data/sequel-activerecord_connection.gemspec +3 -4
- metadata +6 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 042736dc5ad00fd808dd145caa564065a11926b9bdc93698fed9a8f5b0e4aff9
|
|
4
|
+
data.tar.gz: 909816335c6b1001c605fff430bab10853c0746b2c21bd0741c4e8db58164abb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb1cc2a21b801ec092e6e7b9fa7980f5a340371d72b8d4ab7afaec58f5a7eb9b2362292c9397eab2a4e6f80aa7e930b90d89cc07c617b884ac28e982bdeb7978
|
|
7
|
+
data.tar.gz: ad0b5848a8348e2566d1f1c7f51289de04aa4eba2549172c3f375f97dc06435f5bbe669426aef82ffad02cc0b0a1db63e0f76b11fdbba3bd4b021776a43ecf2a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 2.0.1 (2025-10-25)
|
|
2
|
+
|
|
3
|
+
* Allow Active Record 8.1+ (@janko)
|
|
4
|
+
|
|
5
|
+
## 2.0.0 (2024-11-10)
|
|
6
|
+
|
|
7
|
+
* The `after_commit_everywhere` gem now needs to be added to the Gemfile manually on Active Record < 7.2 (@janko)
|
|
8
|
+
|
|
1
9
|
## 1.5.1 (2024-11-08)
|
|
2
10
|
|
|
3
11
|
* Add support for Active Record 8.0 (@phlipper)
|
data/README.md
CHANGED
|
@@ -27,27 +27,10 @@ an Active Record transaction, that query won't actually be executed inside a
|
|
|
27
27
|
database transaction. This is because transactions are tied to the database
|
|
28
28
|
connection; if one connection opens a transaction, this doesn't affect queries
|
|
29
29
|
executed on a different connection, even if both connections are used in the
|
|
30
|
-
same ruby process.
|
|
31
|
-
seamlessly combined between Active Record and Sequel.
|
|
30
|
+
same ruby process.
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Active Record, to make commands such as `rails db:create` and `rails db:drop`
|
|
36
|
-
work. You'd also need to find a way for system tests and the app running in the
|
|
37
|
-
background to share the same database connection, which is something Sequel
|
|
38
|
-
wasn't designed for. Reusing Active Record's connection means (dis)connecting
|
|
39
|
-
and sharing between threads is all handled automatically.
|
|
40
|
-
|
|
41
|
-
## Framework Agnostic
|
|
42
|
-
|
|
43
|
-
The only hard dependencies are:
|
|
44
|
-
|
|
45
|
-
* [ActiveRecord](https://github.com/rails/rails/tree/main/activerecord)
|
|
46
|
-
* [Sequel](https://github.com/jeremyevans/sequel)
|
|
47
|
-
* [after_commit_everywhere](https://github.com/Envek/after_commit_everywhere) (on Active Record 7.1 or older)
|
|
48
|
-
|
|
49
|
-
...which means you can use it with any Rack / Ruby based framework:
|
|
50
|
-
Rails / Roda / Sinatra etc. or even without a framework.
|
|
32
|
+
With this library, transactions and queries can be seamlessly combined between
|
|
33
|
+
Active Record and Sequel.
|
|
51
34
|
|
|
52
35
|
## Installation
|
|
53
36
|
|
|
@@ -57,6 +40,12 @@ Add the gem to your project:
|
|
|
57
40
|
$ bundle add sequel-activerecord_connection
|
|
58
41
|
```
|
|
59
42
|
|
|
43
|
+
If you're using Active Record 7.1 or older, you'll also need to add the [after_commit_everywhere] gem:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
$ bundle add after_commit_everywhere # on Active Record 7.1 or older
|
|
47
|
+
```
|
|
48
|
+
|
|
60
49
|
## Usage
|
|
61
50
|
|
|
62
51
|
Assuming you've configured your ActiveRecord connection, you can initialize the
|
|
@@ -67,7 +56,7 @@ appropriate Sequel adapter and load the `activerecord_connection` extension: e.g
|
|
|
67
56
|
# e.g. Rails: config/initializers/sequel.rb
|
|
68
57
|
|
|
69
58
|
require "sequel"
|
|
70
|
-
DB = Sequel.postgres(extensions: :activerecord_connection) #
|
|
59
|
+
DB = Sequel.postgres(extensions: :activerecord_connection) # for PostgreSQL
|
|
71
60
|
```
|
|
72
61
|
|
|
73
62
|
Now any Sequel operations that you make will internaly be done using the
|
|
@@ -286,3 +275,4 @@ Everyone interacting in this project's codebases, issue trackers, chat rooms and
|
|
|
286
275
|
[Oracle enhanced]: https://github.com/rsim/oracle-enhanced
|
|
287
276
|
[SQL Server]: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
|
|
288
277
|
[sql_log_normalizer]: https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/sql_log_normalizer_rb.html
|
|
278
|
+
[after_commit_everywhere]: https://github.com/Envek/after_commit_everywhere
|
|
@@ -118,8 +118,7 @@ module Sequel
|
|
|
118
118
|
|
|
119
119
|
# When Active Record holds the transaction, we cannot use Sequel hooks,
|
|
120
120
|
# because Sequel doesn't have knowledge of when the transaction is
|
|
121
|
-
# committed. So in this case we register
|
|
122
|
-
# after_commit_everywhere gem.
|
|
121
|
+
# committed. So in this case we register the hook using Active Record.
|
|
123
122
|
def add_transaction_hook(conn, type, block)
|
|
124
123
|
if _trans(conn)[:activerecord]
|
|
125
124
|
activerecord_transaction_callback(type, &block)
|
|
@@ -130,8 +129,7 @@ module Sequel
|
|
|
130
129
|
|
|
131
130
|
# When Active Record holds the savepoint, we cannot use Sequel hooks,
|
|
132
131
|
# because Sequel doesn't have knowledge of when the savepoint is
|
|
133
|
-
# released. So in this case we register
|
|
134
|
-
# after_commit_everywhere gem.
|
|
132
|
+
# released. So in this case we register the hook using Active Record.
|
|
135
133
|
def add_savepoint_hook(conn, type, block)
|
|
136
134
|
if _trans(conn)[:savepoints].last[:activerecord]
|
|
137
135
|
activerecord_transaction_callback(type, &block)
|
|
@@ -145,7 +143,12 @@ module Sequel
|
|
|
145
143
|
activerecord_connection.current_transaction.public_send(type, &block)
|
|
146
144
|
end
|
|
147
145
|
else
|
|
148
|
-
|
|
146
|
+
begin
|
|
147
|
+
gem "after_commit_everywhere", "~> 1.1"
|
|
148
|
+
require "after_commit_everywhere"
|
|
149
|
+
rescue LoadError
|
|
150
|
+
fail Error, %q(You need to add `gem "after_commit_everywhere", "~> 1.1"` to your Gemfile when using Active Record < 7.2)
|
|
151
|
+
end
|
|
149
152
|
|
|
150
153
|
def activerecord_transaction_callback(type, &block)
|
|
151
154
|
AfterCommitEverywhere.public_send(type, &block)
|
|
@@ -191,18 +194,12 @@ module Sequel
|
|
|
191
194
|
# Active Record doesn't guarantee that a single connection can only be used
|
|
192
195
|
# by one thread at a time, so we need to use locking, which is what Active
|
|
193
196
|
# Record does internally as well.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
yield
|
|
199
|
-
end
|
|
197
|
+
def activerecord_lock
|
|
198
|
+
activerecord_connection.lock.synchronize do
|
|
199
|
+
ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
|
|
200
|
+
yield
|
|
200
201
|
end
|
|
201
202
|
end
|
|
202
|
-
else
|
|
203
|
-
def activerecord_lock
|
|
204
|
-
yield
|
|
205
|
-
end
|
|
206
203
|
end
|
|
207
204
|
|
|
208
205
|
def activerecord_connection
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Gem::Specification.new do |spec|
|
|
2
2
|
spec.name = "sequel-activerecord_connection"
|
|
3
|
-
spec.version = "
|
|
3
|
+
spec.version = "2.0.1"
|
|
4
4
|
spec.authors = ["Janko Marohnić"]
|
|
5
|
-
spec.email = ["janko
|
|
5
|
+
spec.email = ["janko@hey.com"]
|
|
6
6
|
|
|
7
7
|
spec.summary = %q{Allows Sequel to use ActiveRecord connection for database interaction.}
|
|
8
8
|
spec.description = %q{Allows Sequel to use ActiveRecord connection for database interaction.}
|
|
@@ -12,8 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.required_ruby_version = ">= 2.5"
|
|
13
13
|
|
|
14
14
|
spec.add_dependency "sequel", "~> 5.38"
|
|
15
|
-
spec.add_dependency "activerecord", ">= 5.
|
|
16
|
-
spec.add_dependency "after_commit_everywhere", "~> 1.1"
|
|
15
|
+
spec.add_dependency "activerecord", ">= 5.1"
|
|
17
16
|
|
|
18
17
|
spec.add_development_dependency "sequel_pg" unless RUBY_ENGINE == "jruby"
|
|
19
18
|
spec.add_development_dependency "minitest"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sequel-activerecord_connection
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Janko Marohnić
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: sequel
|
|
@@ -30,34 +29,14 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '5.
|
|
34
|
-
- - "<"
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: '8.1'
|
|
32
|
+
version: '5.1'
|
|
37
33
|
type: :runtime
|
|
38
34
|
prerelease: false
|
|
39
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
40
36
|
requirements:
|
|
41
37
|
- - ">="
|
|
42
38
|
- !ruby/object:Gem::Version
|
|
43
|
-
version: '5.
|
|
44
|
-
- - "<"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '8.1'
|
|
47
|
-
- !ruby/object:Gem::Dependency
|
|
48
|
-
name: after_commit_everywhere
|
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.1'
|
|
54
|
-
type: :runtime
|
|
55
|
-
prerelease: false
|
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
requirements:
|
|
58
|
-
- - "~>"
|
|
59
|
-
- !ruby/object:Gem::Version
|
|
60
|
-
version: '1.1'
|
|
39
|
+
version: '5.1'
|
|
61
40
|
- !ruby/object:Gem::Dependency
|
|
62
41
|
name: sequel_pg
|
|
63
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,7 +81,7 @@ dependencies:
|
|
|
102
81
|
version: '0'
|
|
103
82
|
description: Allows Sequel to use ActiveRecord connection for database interaction.
|
|
104
83
|
email:
|
|
105
|
-
- janko
|
|
84
|
+
- janko@hey.com
|
|
106
85
|
executables: []
|
|
107
86
|
extensions: []
|
|
108
87
|
extra_rdoc_files: []
|
|
@@ -123,7 +102,6 @@ homepage: https://github.com/janko/sequel-activerecord_connection
|
|
|
123
102
|
licenses:
|
|
124
103
|
- MIT
|
|
125
104
|
metadata: {}
|
|
126
|
-
post_install_message:
|
|
127
105
|
rdoc_options: []
|
|
128
106
|
require_paths:
|
|
129
107
|
- lib
|
|
@@ -138,8 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
138
116
|
- !ruby/object:Gem::Version
|
|
139
117
|
version: '0'
|
|
140
118
|
requirements: []
|
|
141
|
-
rubygems_version: 3.
|
|
142
|
-
signing_key:
|
|
119
|
+
rubygems_version: 3.6.9
|
|
143
120
|
specification_version: 4
|
|
144
121
|
summary: Allows Sequel to use ActiveRecord connection for database interaction.
|
|
145
122
|
test_files: []
|