sequel-activerecord_connection 1.3.1 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +2 -2
- data/lib/sequel/extensions/activerecord_connection.rb +23 -15
- data/sequel-activerecord_connection.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e3934544ded0f6495b75e5a04a8a9adb1d98d9d6b5d76420c45b72c94a4898
|
4
|
+
data.tar.gz: 44fcd4c9c5b5c0f3c1fc9804b9ae3568aca9d7d2623fbb3e3181b52c1e2acc2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 560c34801be1e01717c4d1939ab5745c473df770dbe0d6366ad6cf9f14fe2b7920ae0bd39c8b59b602a70b12a1bbeb3ef34522c02410ad7c6a1d8fb8139340dc
|
7
|
+
data.tar.gz: fe7b20203fafa3414360e5cee9aeb6994b0205838dc82abcc83c9a03b17a8e707c69c49c5f06c4ec6c4019216d80a1e6b0c0f843a935ef11c35601a323064146
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 1.4.1 (2024-05-10)
|
2
|
+
|
3
|
+
* Fix `#rollback_checker`, `#rollback_on_exit` and `#after_rollback` not working reliably on JRuby and Sequel 5.78+ (@janko)
|
4
|
+
|
5
|
+
* Use native transaction callbacks on Active Record 7.2+ (@janko)
|
6
|
+
|
7
|
+
## 1.4.0 (2024-03-19)
|
8
|
+
|
9
|
+
* Only warn when Sequel extension fails to initialize because there is no database (@janko)
|
10
|
+
|
11
|
+
* Drop support for Active Record 4.2 (@janko)
|
12
|
+
|
1
13
|
## 1.3.1 (2023-04-22)
|
2
14
|
|
3
15
|
* Fix Active Record's query cache not being cleared in SQLite adapter (@janko)
|
data/README.md
CHANGED
@@ -8,8 +8,8 @@ This can be useful if you want to use a library that uses Sequel (e.g.
|
|
8
8
|
or if you just want to use Sequel for more complex queries, and you want to
|
9
9
|
avoid creating new database connections.
|
10
10
|
|
11
|
-
It works on ActiveRecord 4.2+ and fully supports PostgresSQL, MySQL and SQLite
|
12
|
-
|
11
|
+
It works on ActiveRecord 4.2+ and fully supports PostgresSQL, MySQL and SQLite,
|
12
|
+
both the native adapters and JDBC (JRuby). The [SQL Server] external adapter is
|
13
13
|
supported as well (`tinytds` in Sequel), and there is attempted support for
|
14
14
|
[Oracle enhanced] (`oracle` and in Sequel). Other adapters might work too, but
|
15
15
|
their integration hasn't been tested.
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "after_commit_everywhere"
|
4
|
-
|
5
3
|
module Sequel
|
6
4
|
module ActiveRecordConnection
|
7
5
|
Error = Class.new(Sequel::Error)
|
@@ -16,6 +14,7 @@ module Sequel
|
|
16
14
|
def self.extended(db)
|
17
15
|
db.activerecord_model = ActiveRecord::Base
|
18
16
|
db.opts[:test] = false unless db.opts.key?(:test)
|
17
|
+
db.instance_variable_set(:@transactions, {}) if RUBY_ENGINE == "jruby"
|
19
18
|
|
20
19
|
begin
|
21
20
|
require "sequel/extensions/activerecord_connection/#{db.adapter_scheme}"
|
@@ -32,6 +31,12 @@ module Sequel
|
|
32
31
|
raise Error, "creating a Sequel connection is not allowed"
|
33
32
|
end
|
34
33
|
|
34
|
+
def extension(*)
|
35
|
+
super
|
36
|
+
rescue ActiveRecord::NoDatabaseError
|
37
|
+
warn "Sequel database extension #{@loaded_extensions.last.inspect} failed to initialize because there is no database."
|
38
|
+
end
|
39
|
+
|
35
40
|
# Avoid calling Sequel's connection pool, instead use Active Record's.
|
36
41
|
def synchronize(*)
|
37
42
|
activerecord_lock do
|
@@ -43,6 +48,8 @@ module Sequel
|
|
43
48
|
|
44
49
|
yield conn
|
45
50
|
end
|
51
|
+
ensure
|
52
|
+
clear_activerecord_query_cache
|
46
53
|
end
|
47
54
|
|
48
55
|
# Log executed queries into Active Record logger as well.
|
@@ -57,17 +64,6 @@ module Sequel
|
|
57
64
|
@timezone || activerecord_timezone
|
58
65
|
end
|
59
66
|
|
60
|
-
# Clear Active Record's query cache after potential data modifications.
|
61
|
-
%i[execute_ddl execute_dui execute_insert execute].each do |execute_method|
|
62
|
-
define_method(execute_method) do |*args, &block|
|
63
|
-
begin
|
64
|
-
super(*args, &block)
|
65
|
-
ensure
|
66
|
-
clear_activerecord_query_cache
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
67
|
private
|
72
68
|
|
73
69
|
# Synchronizes transaction state with ActiveRecord. Sequel uses this
|
@@ -123,7 +119,7 @@ module Sequel
|
|
123
119
|
# after_commit_everywhere gem.
|
124
120
|
def add_transaction_hook(conn, type, block)
|
125
121
|
if _trans(conn)[:activerecord]
|
126
|
-
|
122
|
+
activerecord_transaction_callback(type, &block)
|
127
123
|
else
|
128
124
|
super
|
129
125
|
end
|
@@ -135,12 +131,24 @@ module Sequel
|
|
135
131
|
# after_commit_everywhere gem.
|
136
132
|
def add_savepoint_hook(conn, type, block)
|
137
133
|
if _trans(conn)[:savepoints].last[:activerecord]
|
138
|
-
|
134
|
+
activerecord_transaction_callback(type, &block)
|
139
135
|
else
|
140
136
|
super
|
141
137
|
end
|
142
138
|
end
|
143
139
|
|
140
|
+
if ActiveRecord.version >= Gem::Version.new("7.2.0.alpha")
|
141
|
+
def activerecord_transaction_callback(type, &block)
|
142
|
+
activerecord_connection.current_transaction.public_send(type, &block)
|
143
|
+
end
|
144
|
+
else
|
145
|
+
require "after_commit_everywhere"
|
146
|
+
|
147
|
+
def activerecord_transaction_callback(type, &block)
|
148
|
+
AfterCommitEverywhere.public_send(type, &block)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
144
152
|
# Prevents sql_log_normalizer DB extension from skipping the normalization.
|
145
153
|
def skip_logging?
|
146
154
|
return false if @loaded_extensions.include?(:sql_log_normalizer)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "sequel-activerecord_connection"
|
3
|
-
spec.version = "1.
|
3
|
+
spec.version = "1.4.1"
|
4
4
|
spec.authors = ["Janko Marohnić"]
|
5
5
|
spec.email = ["janko.marohnic@gmail.com"]
|
6
6
|
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.required_ruby_version = ">= 2.4"
|
13
13
|
|
14
14
|
spec.add_dependency "sequel", "~> 5.38"
|
15
|
-
spec.add_dependency "activerecord", ">=
|
15
|
+
spec.add_dependency "activerecord", ">= 5.0", "< 8"
|
16
16
|
spec.add_dependency "after_commit_everywhere", "~> 1.1"
|
17
17
|
|
18
18
|
spec.add_development_dependency "sequel_pg" unless RUBY_ENGINE == "jruby"
|
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.4.1
|
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: 2024-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '5.0'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '8'
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '
|
43
|
+
version: '5.0'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '8'
|
@@ -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.5.9
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Allows Sequel to use ActiveRecord connection for database interaction.
|