sequel 5.77.0 → 5.81.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +35 -1
- data/README.rdoc +5 -3
- data/doc/code_order.rdoc +5 -3
- data/doc/dataset_basics.rdoc +1 -1
- data/doc/opening_databases.rdoc +2 -0
- data/doc/querying.rdoc +6 -1
- data/doc/release_notes/5.78.0.txt +67 -0
- data/doc/release_notes/5.79.0.txt +28 -0
- data/doc/release_notes/5.80.0.txt +40 -0
- data/doc/release_notes/5.81.0.txt +31 -0
- data/doc/schema_modification.rdoc +2 -2
- data/lib/sequel/adapters/shared/mssql.rb +29 -1
- data/lib/sequel/adapters/shared/mysql.rb +37 -2
- data/lib/sequel/adapters/shared/postgres.rb +37 -2
- data/lib/sequel/database/misc.rb +1 -0
- data/lib/sequel/database/schema_methods.rb +2 -2
- data/lib/sequel/dataset/dataset_module.rb +1 -1
- data/lib/sequel/dataset/graph.rb +1 -0
- data/lib/sequel/dataset/query.rb +58 -9
- data/lib/sequel/exceptions.rb +5 -0
- data/lib/sequel/extensions/async_thread_pool.rb +7 -0
- data/lib/sequel/extensions/caller_logging.rb +4 -1
- data/lib/sequel/extensions/migration.rb +12 -1
- data/lib/sequel/extensions/provenance.rb +110 -0
- data/lib/sequel/extensions/sqlite_json_ops.rb +76 -18
- data/lib/sequel/extensions/temporarily_release_connection.rb +178 -0
- data/lib/sequel/model/base.rb +1 -1
- data/lib/sequel/plugins/column_encryption.rb +1 -1
- data/lib/sequel/plugins/input_transformer.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- metadata +13 -3
@@ -0,0 +1,178 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
#
|
3
|
+
# The temporarily_release_connection extension adds support for temporarily
|
4
|
+
# releasing a checked out connection back to the connection pool. It is
|
5
|
+
# designed for use in multithreaded transactional integration tests, allowing
|
6
|
+
# a connection to start a transaction in one thread, but be temporarily
|
7
|
+
# released back to the connection pool, so it can be operated on safely
|
8
|
+
# by multiple threads inside a block. For example, the main thread could be
|
9
|
+
# running tests that send web requests, and a separate thread running a web
|
10
|
+
# server that is responding to those requests, and the same connection and
|
11
|
+
# transaction would be used for both.
|
12
|
+
#
|
13
|
+
# To load the extension into the database:
|
14
|
+
#
|
15
|
+
# DB.extension :temporarily_release_connection
|
16
|
+
#
|
17
|
+
# After the extension is loaded, call the +temporarily_release_connection+
|
18
|
+
# method with the connection object to temporarily release the connection
|
19
|
+
# back to the pool. Example:
|
20
|
+
#
|
21
|
+
# DB.transaction(rollback: :always, auto_savepoint: true) do |conn|
|
22
|
+
# DB.temporarily_release_connection(conn) do
|
23
|
+
# # Other threads can operate on connection safely inside the transaction
|
24
|
+
# yield
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# For sharded connection pools, the second argument to +temporarily_release_connection+
|
29
|
+
# is respected, and specifies the server on which to temporarily release the connection.
|
30
|
+
#
|
31
|
+
# The temporarily_release_connection extension is only supported with the
|
32
|
+
# threaded and timed_queue connection pools that ship with Sequel (and the sharded
|
33
|
+
# versions of each). To make sure that same connection object can be reacquired, it
|
34
|
+
# is only supported if the maximum connection pool size is 1, so set the Database
|
35
|
+
# :max_connections option to 1 if you plan to use this extension.
|
36
|
+
#
|
37
|
+
# If the +temporarily_release_connection+ method cannot reacquire the same connection
|
38
|
+
# it released to the pool, it will raise a Sequel::UnableToReacquireConnectionError
|
39
|
+
# exception. This should only happen if the connection has been disconnected
|
40
|
+
# while it was temporarily released. If this error is raised, Database#transaction
|
41
|
+
# will not rollback the transaction, since the connection object is likely no longer
|
42
|
+
# valid, and on poorly written database drivers, that could cause the process to crash.
|
43
|
+
#
|
44
|
+
# Related modules: Sequel::TemporarilyReleaseConnection,
|
45
|
+
# Sequel::UnableToReacquireConnectionError
|
46
|
+
|
47
|
+
#
|
48
|
+
module Sequel
|
49
|
+
# Error class raised if the connection pool does not provide the same connection
|
50
|
+
# object when checking a temporarily released connection out.
|
51
|
+
class UnableToReacquireConnectionError < Error
|
52
|
+
end
|
53
|
+
|
54
|
+
module TemporarilyReleaseConnection
|
55
|
+
module DatabaseMethods
|
56
|
+
# Temporarily release the connection back to the connection pool for the
|
57
|
+
# duration of the block.
|
58
|
+
def temporarily_release_connection(conn, server=:default, &block)
|
59
|
+
pool.temporarily_release_connection(conn, server, &block)
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
# Do nothing if UnableToReacquireConnectionError is raised, as it is
|
65
|
+
# likely the connection is not in a usable state.
|
66
|
+
def rollback_transaction(conn, opts)
|
67
|
+
return if UnableToReacquireConnectionError === $!
|
68
|
+
super
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
module PoolMethods
|
73
|
+
# Temporarily release a currently checked out connection, then yield to the block. Reacquire the same
|
74
|
+
# connection upon the exit of the block.
|
75
|
+
def temporarily_release_connection(conn, server)
|
76
|
+
t = Sequel.current
|
77
|
+
raise Error, "connection not currently checked out" unless conn.equal?(trc_owned_connection(t, server))
|
78
|
+
|
79
|
+
begin
|
80
|
+
trc_release(t, conn, server)
|
81
|
+
yield
|
82
|
+
ensure
|
83
|
+
c = trc_acquire(t, server)
|
84
|
+
unless conn.equal?(c)
|
85
|
+
raise UnableToReacquireConnectionError, "reacquired connection not the same as initial connection"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
module TimedQueue
|
92
|
+
private
|
93
|
+
|
94
|
+
def trc_owned_connection(t, server)
|
95
|
+
owned_connection(t)
|
96
|
+
end
|
97
|
+
|
98
|
+
def trc_release(t, conn, server)
|
99
|
+
release(t)
|
100
|
+
end
|
101
|
+
|
102
|
+
def trc_acquire(t, server)
|
103
|
+
acquire(t)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
module ShardedTimedQueue
|
108
|
+
# Normalize the server name for sharded connection pools
|
109
|
+
def temporarily_release_connection(conn, server)
|
110
|
+
server = pick_server(server)
|
111
|
+
super
|
112
|
+
end
|
113
|
+
|
114
|
+
private
|
115
|
+
|
116
|
+
def trc_owned_connection(t, server)
|
117
|
+
owned_connection(t, server)
|
118
|
+
end
|
119
|
+
|
120
|
+
def trc_release(t, conn, server)
|
121
|
+
release(t, conn, server)
|
122
|
+
end
|
123
|
+
|
124
|
+
def trc_acquire(t, server)
|
125
|
+
acquire(t, server)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
module ThreadedBase
|
130
|
+
private
|
131
|
+
|
132
|
+
def trc_release(t, conn, server)
|
133
|
+
sync{super}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
module Threaded
|
138
|
+
include TimedQueue
|
139
|
+
include ThreadedBase
|
140
|
+
end
|
141
|
+
|
142
|
+
module ShardedThreaded
|
143
|
+
include ShardedTimedQueue
|
144
|
+
include ThreadedBase
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
trc = TemporarilyReleaseConnection
|
149
|
+
trc_map = {
|
150
|
+
:threaded => trc::Threaded,
|
151
|
+
:sharded_threaded => trc::ShardedThreaded,
|
152
|
+
:timed_queue => trc::TimedQueue,
|
153
|
+
:sharded_timed_queue => trc::ShardedTimedQueue,
|
154
|
+
}.freeze
|
155
|
+
|
156
|
+
Database.register_extension(:temporarily_release_connection) do |db|
|
157
|
+
unless pool_mod = trc_map[db.pool.pool_type]
|
158
|
+
raise(Error, "temporarily_release_connection extension not supported for connection pool type #{db.pool.pool_type}")
|
159
|
+
end
|
160
|
+
|
161
|
+
case db.pool.pool_type
|
162
|
+
when :threaded, :sharded_threaded
|
163
|
+
if db.opts[:connection_handling] == :disconnect
|
164
|
+
raise Error, "temporarily_release_connection extension not supported with connection_handling: :disconnect option"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
unless db.pool.max_size == 1
|
169
|
+
raise Error, "temporarily_release_connection extension not supported unless :max_connections option is 1"
|
170
|
+
end
|
171
|
+
|
172
|
+
db.extend(trc::DatabaseMethods)
|
173
|
+
db.pool.extend(trc::PoolMethods)
|
174
|
+
db.pool.extend(pool_mod)
|
175
|
+
end
|
176
|
+
|
177
|
+
private_constant :TemporarilyReleaseConnection
|
178
|
+
end
|
data/lib/sequel/model/base.rb
CHANGED
@@ -17,7 +17,7 @@ module Sequel
|
|
17
17
|
# natural_join, natural_left_join, natural_right_join, offset, order, order_append, order_by,
|
18
18
|
# order_more, order_prepend, paged_each, qualify, reverse, reverse_order, right_join,
|
19
19
|
# right_outer_join, select, select_all, select_append, select_group, select_hash,
|
20
|
-
# select_hash_groups, select_map, select_more, select_order_map, server,
|
20
|
+
# select_hash_groups, select_map, select_more, select_order_map, select_prepend, server,
|
21
21
|
# single_record, single_record!, single_value, single_value!, sum, to_hash, to_hash_groups,
|
22
22
|
# truncate, unfiltered, ungraphed, ungrouped, union, unlimited, unordered, where, where_all,
|
23
23
|
# where_each, where_single_value, with, with_recursive, with_sql
|
@@ -24,7 +24,7 @@ module Sequel
|
|
24
24
|
# # Make the Album class support input transformers
|
25
25
|
# Album.plugin :input_transformer
|
26
26
|
module InputTransformer
|
27
|
-
def self.apply(model,
|
27
|
+
def self.apply(model, *, &_)
|
28
28
|
model.instance_exec do
|
29
29
|
@input_transformers = {}
|
30
30
|
@skip_input_transformer_columns = {}
|
data/lib/sequel/version.rb
CHANGED
@@ -6,7 +6,7 @@ module Sequel
|
|
6
6
|
|
7
7
|
# The minor version of Sequel. Bumped for every non-patch level
|
8
8
|
# release, generally around once a month.
|
9
|
-
MINOR =
|
9
|
+
MINOR = 81
|
10
10
|
|
11
11
|
# The tiny version of Sequel. Usually 0, only bumped for bugfix
|
12
12
|
# releases that fix regressions from previous versions.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.81.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|
@@ -224,7 +224,11 @@ extra_rdoc_files:
|
|
224
224
|
- doc/release_notes/5.75.0.txt
|
225
225
|
- doc/release_notes/5.76.0.txt
|
226
226
|
- doc/release_notes/5.77.0.txt
|
227
|
+
- doc/release_notes/5.78.0.txt
|
228
|
+
- doc/release_notes/5.79.0.txt
|
227
229
|
- doc/release_notes/5.8.0.txt
|
230
|
+
- doc/release_notes/5.80.0.txt
|
231
|
+
- doc/release_notes/5.81.0.txt
|
228
232
|
- doc/release_notes/5.9.0.txt
|
229
233
|
files:
|
230
234
|
- CHANGELOG
|
@@ -329,7 +333,11 @@ files:
|
|
329
333
|
- doc/release_notes/5.75.0.txt
|
330
334
|
- doc/release_notes/5.76.0.txt
|
331
335
|
- doc/release_notes/5.77.0.txt
|
336
|
+
- doc/release_notes/5.78.0.txt
|
337
|
+
- doc/release_notes/5.79.0.txt
|
332
338
|
- doc/release_notes/5.8.0.txt
|
339
|
+
- doc/release_notes/5.80.0.txt
|
340
|
+
- doc/release_notes/5.81.0.txt
|
333
341
|
- doc/release_notes/5.9.0.txt
|
334
342
|
- doc/schema_modification.rdoc
|
335
343
|
- doc/security.rdoc
|
@@ -492,6 +500,7 @@ files:
|
|
492
500
|
- lib/sequel/extensions/pg_static_cache_updater.rb
|
493
501
|
- lib/sequel/extensions/pg_timestamptz.rb
|
494
502
|
- lib/sequel/extensions/pretty_table.rb
|
503
|
+
- lib/sequel/extensions/provenance.rb
|
495
504
|
- lib/sequel/extensions/query.rb
|
496
505
|
- lib/sequel/extensions/round_timestamps.rb
|
497
506
|
- lib/sequel/extensions/run_transaction_hooks.rb
|
@@ -515,6 +524,7 @@ files:
|
|
515
524
|
- lib/sequel/extensions/symbol_as.rb
|
516
525
|
- lib/sequel/extensions/symbol_as_refinement.rb
|
517
526
|
- lib/sequel/extensions/synchronize_sql.rb
|
527
|
+
- lib/sequel/extensions/temporarily_release_connection.rb
|
518
528
|
- lib/sequel/extensions/thread_local_timezones.rb
|
519
529
|
- lib/sequel/extensions/to_dot.rb
|
520
530
|
- lib/sequel/extensions/transaction_connection_validator.rb
|
@@ -662,7 +672,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
662
672
|
- !ruby/object:Gem::Version
|
663
673
|
version: '0'
|
664
674
|
requirements: []
|
665
|
-
rubygems_version: 3.5.
|
675
|
+
rubygems_version: 3.5.9
|
666
676
|
signing_key:
|
667
677
|
specification_version: 4
|
668
678
|
summary: The Database Toolkit for Ruby
|