sequel-activerecord_connection 1.2.6 → 1.2.9
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 +13 -1
- data/LICENSE.txt +1 -1
- data/README.md +37 -14
- data/lib/sequel/extensions/activerecord_connection/postgres.rb +8 -3
- data/sequel-activerecord_connection.gemspec +3 -3
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cd2f9d2df2e116227a94f6a005a5f7470178e4ecfc22218fe0a3dc456a2ecd2
|
4
|
+
data.tar.gz: 64e96f773827d185768d6190468a350162c3e7e4923a5f5dc565d50ec8064f79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58862596df481839c1668ce4f3062f56255dc5115a2aa8bfb08499c10b76eac0859b51485f639c5fa16459cff170c2531b7c86c0e38efe9d5dfe6bc94a6a2891
|
7
|
+
data.tar.gz: 1aa33eb5cd5eb85be84252bd3ddd02ec537e7bf89481882604fc691d72d055d4bd85e6ad97562c44b39c90beabb661ba04ba1a311775b707aa71984f23dc8e25
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
|
+
## 1.2.9 (2022-03-15)
|
2
|
+
|
3
|
+
* Remove `sequel_pg` and `pg` runtime dependencies introduced in the previous version (@janko)
|
4
|
+
|
5
|
+
## 1.2.8 (2022-02-28)
|
6
|
+
|
7
|
+
* Support the pg_streaming database extension from the sequel_pg gem (@janko)
|
8
|
+
|
9
|
+
## 1.2.7 (2022-01-20)
|
10
|
+
|
11
|
+
* Require Sequel 3.38+ (@janko)
|
12
|
+
|
1
13
|
## 1.2.6 (2021-12-26)
|
2
14
|
|
3
|
-
* Speed up
|
15
|
+
* Speed up connection access by avoiding checking Active Record version at runtime (@janko)
|
4
16
|
|
5
17
|
## 1.2.5 (2021-12-19)
|
6
18
|
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,18 +1,42 @@
|
|
1
1
|
# sequel-activerecord_connection
|
2
2
|
|
3
|
-
This is
|
4
|
-
|
3
|
+
This is a database extension for [Sequel] that makes it to reuse an existing
|
4
|
+
Active Record connection for database interaction.
|
5
5
|
|
6
|
-
This can be useful if you
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
This can be useful if you want to use a library that uses Sequel (e.g.
|
7
|
+
[Rodauth] or [rom-sql]), or you're transitioning from Active Record to Sequel,
|
8
|
+
or if you just want to use Sequel for more complex queries, and you want to
|
9
|
+
avoid creating new database connections.
|
10
10
|
|
11
11
|
It works on ActiveRecord 4.2+ and fully supports PostgresSQL, MySQL and SQLite
|
12
|
-
adapters, both
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
adapters, both native and JDBC (JRuby). There is attempted suppport for [Oracle
|
13
|
+
enhanced] and [SQL Server] Active Record adapters (`oracle` and `tinytds` in
|
14
|
+
Sequel). Other adapters might work too, but their integration hasn't been
|
15
|
+
tested.
|
16
|
+
|
17
|
+
## Why reuse the database connection?
|
18
|
+
|
19
|
+
At first it might appear that, as long as you're fine with the performance
|
20
|
+
impact of your database server having to maintain additional open connections,
|
21
|
+
it would be fine if Sequel had its own database connection. However, there are
|
22
|
+
additional caveats when you try to combine it with Active Record.
|
23
|
+
|
24
|
+
If Sequel and Active Record each have their own connections, then it's not
|
25
|
+
possible to combine their transactions. If we executed a Sequel query inside of
|
26
|
+
an Active Record transaction, that query won't actually be executed inside a
|
27
|
+
database transaction. This is because transactions are tied to the database
|
28
|
+
connection; if one connection opens a transaction, this doesn't affect queries
|
29
|
+
executed on a different connection, even if both connections are used in the
|
30
|
+
same ruby process. With this library, transactions and queries can be
|
31
|
+
seamlessly combined between Active Record and Sequel.
|
32
|
+
|
33
|
+
In Rails context, there are additional considerations for a Sequel connection
|
34
|
+
to play nicely. Connecting and disconnecting would have to go in lockstep with
|
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.
|
16
40
|
|
17
41
|
## Installation
|
18
42
|
|
@@ -140,9 +164,8 @@ DB.transaction(auto_savepoint: true) do
|
|
140
164
|
end
|
141
165
|
#>> BEGIN
|
142
166
|
#>> SAVEPOINT active_record_1
|
143
|
-
#>>
|
167
|
+
#>> ROLLBACK TO SAVEPOINT active_record_1
|
144
168
|
#>> COMMIT
|
145
|
-
#>> after commit
|
146
169
|
```
|
147
170
|
|
148
171
|
In case of (a) adding a transaction hook while Active Record holds the
|
@@ -168,13 +191,13 @@ end
|
|
168
191
|
# after a savepoint is released, if the enclosing transaction is not joinable.
|
169
192
|
ActiveRecord::Base.transaction(joinable: false) do
|
170
193
|
DB.transaction do
|
171
|
-
DB.after_commit { puts "after
|
194
|
+
DB.after_commit { puts "after savepoint release" }
|
172
195
|
end
|
173
196
|
end
|
174
197
|
#>> BEGIN
|
175
198
|
#>> SAVEPOINT active_record_1
|
176
199
|
#>> RELEASE SAVEPOINT active_record_1
|
177
|
-
#>> after
|
200
|
+
#>> after savepoint release
|
178
201
|
#>> COMMIT
|
179
202
|
```
|
180
203
|
|
@@ -10,6 +10,11 @@ module Sequel
|
|
10
10
|
|
11
11
|
Utils.add_prepared_statements_cache(conn)
|
12
12
|
|
13
|
+
# compatibility for pg_streaming database extension from sequel_pg gem
|
14
|
+
if defined?(Sequel::Postgres::Streaming) && is_a?(Sequel::Postgres::Streaming)
|
15
|
+
conn.extend(Sequel::Postgres::Streaming::AdapterMethods)
|
16
|
+
end
|
17
|
+
|
13
18
|
yield conn
|
14
19
|
end
|
15
20
|
end
|
@@ -70,11 +75,11 @@ module Sequel
|
|
70
75
|
# yield the results, otherwise, return the number of changed rows.
|
71
76
|
def execute(sql, args = nil)
|
72
77
|
args = args.map { |v| @db.bound_variable_arg(v, self) } if args
|
73
|
-
|
78
|
+
q = check_disconnect_errors { execute_query(sql, args) }
|
74
79
|
|
75
|
-
block_given? ? yield(
|
80
|
+
block_given? ? yield(q) : q.cmd_tuples
|
76
81
|
ensure
|
77
|
-
|
82
|
+
q.clear if q && q.respond_to?(:clear)
|
78
83
|
end
|
79
84
|
|
80
85
|
private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "sequel-activerecord_connection"
|
3
|
-
spec.version = "1.2.
|
3
|
+
spec.version = "1.2.9"
|
4
4
|
spec.authors = ["Janko Marohnić"]
|
5
5
|
spec.email = ["janko.marohnic@gmail.com"]
|
6
6
|
|
@@ -11,11 +11,11 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.required_ruby_version = ">= 2.4"
|
13
13
|
|
14
|
-
spec.add_dependency "sequel", "~> 5.
|
14
|
+
spec.add_dependency "sequel", "~> 5.38"
|
15
15
|
spec.add_dependency "activerecord", ">= 4.2", "< 8"
|
16
16
|
spec.add_dependency "after_commit_everywhere", "~> 1.1"
|
17
17
|
|
18
|
-
spec.add_development_dependency "
|
18
|
+
spec.add_development_dependency "sequel_pg" unless RUBY_ENGINE == "jruby"
|
19
19
|
spec.add_development_dependency "minitest"
|
20
20
|
spec.add_development_dependency "warning"
|
21
21
|
|
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.2.
|
4
|
+
version: 1.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '5.
|
19
|
+
version: '5.38'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '5.
|
26
|
+
version: '5.38'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,19 +59,19 @@ dependencies:
|
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '1.1'
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: sequel_pg
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
64
64
|
requirements:
|
65
|
-
- - "
|
65
|
+
- - ">="
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- - "
|
72
|
+
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '0'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: minitest
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.
|
141
|
+
rubygems_version: 3.3.3
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Allows Sequel to use ActiveRecord connection for database interaction.
|