sequel-activerecord_connection 1.5.1 → 2.0.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 +8 -12
- data/lib/sequel/extensions/activerecord_connection.rb +8 -5
- data/sequel-activerecord_connection.gemspec +2 -3
- metadata +3 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2912969fb906ae413ccdded0137055b743786a4fdcf8de812c643d8c0facc6a
|
|
4
|
+
data.tar.gz: 75662cc9ae2f373a106b8c7163bc96fc4ae067a7001f39df166a780648dd9998
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2a2d9c7f5c1b88bb0c8285968f61ae2c8e3dd27df266df9675b14c5ff6fd9eb06a4e37a9a2c4c7638a7fe11405df2a8bfb6b79ae58dda38e8bbafcd29309b07d
|
|
7
|
+
data.tar.gz: 2e73044828506553458070cd5763ce2196706e6a58713dde428182b14f30266aa52a278dcd2a4c0e9d1b71984bb73bd8099351199140ee211c82dadbe9334985
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -38,17 +38,6 @@ background to share the same database connection, which is something Sequel
|
|
|
38
38
|
wasn't designed for. Reusing Active Record's connection means (dis)connecting
|
|
39
39
|
and sharing between threads is all handled automatically.
|
|
40
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.
|
|
51
|
-
|
|
52
41
|
## Installation
|
|
53
42
|
|
|
54
43
|
Add the gem to your project:
|
|
@@ -57,6 +46,12 @@ Add the gem to your project:
|
|
|
57
46
|
$ bundle add sequel-activerecord_connection
|
|
58
47
|
```
|
|
59
48
|
|
|
49
|
+
If you're using Active Record 7.1 or older, you'll also need to add the [after_commit_everywhere] gem:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
$ bundle add after_commit_everywhere # on Active Record 7.1 or older
|
|
53
|
+
```
|
|
54
|
+
|
|
60
55
|
## Usage
|
|
61
56
|
|
|
62
57
|
Assuming you've configured your ActiveRecord connection, you can initialize the
|
|
@@ -67,7 +62,7 @@ appropriate Sequel adapter and load the `activerecord_connection` extension: e.g
|
|
|
67
62
|
# e.g. Rails: config/initializers/sequel.rb
|
|
68
63
|
|
|
69
64
|
require "sequel"
|
|
70
|
-
DB = Sequel.postgres(extensions: :activerecord_connection) #
|
|
65
|
+
DB = Sequel.postgres(extensions: :activerecord_connection) # for PostgreSQL
|
|
71
66
|
```
|
|
72
67
|
|
|
73
68
|
Now any Sequel operations that you make will internaly be done using the
|
|
@@ -286,3 +281,4 @@ Everyone interacting in this project's codebases, issue trackers, chat rooms and
|
|
|
286
281
|
[Oracle enhanced]: https://github.com/rsim/oracle-enhanced
|
|
287
282
|
[SQL Server]: https://github.com/rails-sqlserver/activerecord-sqlserver-adapter
|
|
288
283
|
[sql_log_normalizer]: https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/sql_log_normalizer_rb.html
|
|
284
|
+
[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)
|
|
@@ -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.0"
|
|
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.}
|
|
@@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
|
|
14
14
|
spec.add_dependency "sequel", "~> 5.38"
|
|
15
15
|
spec.add_dependency "activerecord", ">= 5.0", "< 8.1"
|
|
16
|
-
spec.add_dependency "after_commit_everywhere", "~> 1.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,14 @@
|
|
|
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.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-
|
|
11
|
+
date: 2024-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sequel
|
|
@@ -44,20 +44,6 @@ dependencies:
|
|
|
44
44
|
- - "<"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
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'
|
|
61
47
|
- !ruby/object:Gem::Dependency
|
|
62
48
|
name: sequel_pg
|
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -102,7 +88,7 @@ dependencies:
|
|
|
102
88
|
version: '0'
|
|
103
89
|
description: Allows Sequel to use ActiveRecord connection for database interaction.
|
|
104
90
|
email:
|
|
105
|
-
- janko
|
|
91
|
+
- janko@hey.com
|
|
106
92
|
executables: []
|
|
107
93
|
extensions: []
|
|
108
94
|
extra_rdoc_files: []
|