umbrellio-sequel-plugins 0.6.0.36 → 0.6.0.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +43 -0
- data/lib/sequel/extensions/migration_transaction_options.rb +48 -0
- data/lib/sequel/extensions/set_local.rb +22 -0
- data/utils/database.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6300b1ec3023af08e57414d2e3f4f86483d0ec33addb2252ef11bc5d9af33a7f
|
4
|
+
data.tar.gz: 7d75ea75302cddd7287a93fa996615b4491adfac1d93ac1b10c49b906eb4cb74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fa9070b52a12cf73f40fae645931a3cf8f475156446c1206be97692ea71920c0e60ac6e24db38ac44d92e33986cf0d5164073baf3af3c22360c8d9ca45ff0d
|
7
|
+
data.tar.gz: bf2493882e57ae14e9c556fa7f77654ecacde594720a7b65381f75c5d50fc2e1f34e67d88d0d85120de3650485fefccf901816a4d60d6d98446d2e5dc358e471
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,26 @@
|
|
1
1
|
# Changelog
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
## [0.7.0] 2022-06-24
|
5
|
+
### Added
|
6
|
+
- `DB.extension(:set_local)` - allows to set transaction locals;
|
7
|
+
- Support of transaction options via `transaction_options` in migrations;
|
8
|
+
|
9
|
+
## [0.6.0] 2022-06-15
|
10
|
+
### Added
|
11
|
+
- `mode` param for `Sequel::Model.plugin(:with_lock)`, defaults to `FOR NO KEY UPDATE`;
|
12
|
+
|
13
|
+
## [0.5.0] 2020-06-06
|
14
|
+
### Added
|
15
|
+
- `Sequel::Model.plugin(:attr_encrypted)` - encrypts to model attributes;
|
16
|
+
|
4
17
|
## [0.4.0] 2019-11-18
|
5
18
|
### Added
|
6
19
|
- `Sequel.extension(:deferrable_foreign_keys)` - makes foreign keys constraints deferrable by default;
|
7
20
|
|
8
21
|
## [0.3.2] 2018-07-03
|
9
22
|
### Added
|
10
|
-
- Support sequel
|
23
|
+
- Support sequel expressions in `with_rates`;
|
11
24
|
|
12
25
|
## [0.3.0] 2018-04-24
|
13
26
|
### Added
|
data/README.md
CHANGED
@@ -23,6 +23,8 @@ $ bundle
|
|
23
23
|
- [`Synchronize`](#Synchronize)
|
24
24
|
- [`Methods in Migrations`](#Methods-in-Migrations)
|
25
25
|
- [`Deferrable Foreign Keys`](#Deferrable-Foreign-Keys)
|
26
|
+
- [`Set Local`](#Set-Local)
|
27
|
+
- [`Migration Transaction Options`](#Migration-Transaction-Options)
|
26
28
|
|
27
29
|
# Plugins
|
28
30
|
|
@@ -204,6 +206,47 @@ end
|
|
204
206
|
# => <Husband @attributes={id:1, wife_id: 1}>
|
205
207
|
```
|
206
208
|
|
209
|
+
|
210
|
+
## Set Local
|
211
|
+
|
212
|
+
Enable: `DB.extension(:set_local)`
|
213
|
+
|
214
|
+
Makes possible to set transaction locals.
|
215
|
+
|
216
|
+
Example:
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
DB.transaction(set_local: { lock_timeout: "5s", statement_timeout: "5s" }) {}
|
220
|
+
```
|
221
|
+
```sql
|
222
|
+
BEGIN;
|
223
|
+
SET LOCAL lock_timeout = '5s';
|
224
|
+
SET LOCAL statement_timeout = '5s';
|
225
|
+
COMMIT;
|
226
|
+
```
|
227
|
+
|
228
|
+
|
229
|
+
## Migration Transaction Options
|
230
|
+
|
231
|
+
Enable: `Sequel.extension(:migration_transaction_options)`
|
232
|
+
|
233
|
+
Makes possible to pass `transaction_options` in migrations.
|
234
|
+
|
235
|
+
Example:
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
Sequel.migration do
|
239
|
+
transaction_options rollback: :always
|
240
|
+
|
241
|
+
up { DB.select("1") }
|
242
|
+
end
|
243
|
+
```
|
244
|
+
```sql
|
245
|
+
BEGIN;
|
246
|
+
SELECT '1';
|
247
|
+
ROLLBACK;
|
248
|
+
```
|
249
|
+
|
207
250
|
## AttrEncrypted
|
208
251
|
|
209
252
|
Enable: `Sequel::Model.plugin :attr_encrypted`
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MigrationDSLExtension
|
4
|
+
def transaction_options(opts)
|
5
|
+
migration.transaction_opts = opts
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module SimpleMigrationExtension
|
10
|
+
attr_accessor :transaction_opts
|
11
|
+
end
|
12
|
+
|
13
|
+
module MigratorExtension
|
14
|
+
def checked_transaction(migration, &block)
|
15
|
+
if _use_transaction?(migration)
|
16
|
+
_transaction(migration, &block)
|
17
|
+
else
|
18
|
+
yield
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def _use_transaction?(migration)
|
25
|
+
# NOTE: original code
|
26
|
+
if @use_transactions.nil?
|
27
|
+
if migration.use_transactions.nil?
|
28
|
+
@db.supports_transactional_ddl?
|
29
|
+
else
|
30
|
+
migration.use_transactions
|
31
|
+
end
|
32
|
+
else
|
33
|
+
@use_transactions
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def _transaction(migration, &block)
|
38
|
+
if migration.transaction_opts.nil?
|
39
|
+
db.transaction(&block)
|
40
|
+
else
|
41
|
+
db.transaction(migration.transaction_opts, &block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Sequel::MigrationDSL.include(MigrationDSLExtension)
|
47
|
+
Sequel::SimpleMigration.include(SimpleMigrationExtension)
|
48
|
+
Sequel::Migrator.prepend(MigratorExtension)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sequel
|
4
|
+
module SetLocal
|
5
|
+
private
|
6
|
+
|
7
|
+
def begin_new_transaction(conn, opts)
|
8
|
+
super
|
9
|
+
check_set_local(conn, opts[:set_local])
|
10
|
+
end
|
11
|
+
|
12
|
+
def check_set_local(conn, locals)
|
13
|
+
return if locals.nil?
|
14
|
+
|
15
|
+
locals.each do |key, value|
|
16
|
+
log_connection_execute(conn, "SET LOCAL #{key} = \"#{value}\"")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Database.register_extension(:set_local, SetLocal)
|
22
|
+
end
|
data/utils/database.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: umbrellio-sequel-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.0.
|
4
|
+
version: 0.6.0.46
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nulldef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -188,7 +188,9 @@ files:
|
|
188
188
|
- lib/sequel/extensions/currency_rates.rb
|
189
189
|
- lib/sequel/extensions/deferrable_foreign_keys.rb
|
190
190
|
- lib/sequel/extensions/methods_in_migrations.rb
|
191
|
+
- lib/sequel/extensions/migration_transaction_options.rb
|
191
192
|
- lib/sequel/extensions/pg_tools.rb
|
193
|
+
- lib/sequel/extensions/set_local.rb
|
192
194
|
- lib/sequel/extensions/slave.rb
|
193
195
|
- lib/sequel/extensions/synchronize.rb
|
194
196
|
- lib/sequel/plugins/attr_encrypted.rb
|