trx_ext 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cc78b1346a3cff23d72f3114aab76b882ddd1f798a16e21e0fed7b25ee85198
4
- data.tar.gz: 90bc0d7a9810d5307c3eda6571f3d7480eb95c8c2163d036e52cba184c251c00
3
+ metadata.gz: 93b7a1f518fdd40ddeeb90c13f994c3cf437fd7f21a4077dafaa432c26085ae1
4
+ data.tar.gz: bd95308a108f553e964d14a929516bb43b7736a5248f22694b08e5da19ac881b
5
5
  SHA512:
6
- metadata.gz: e5dfa0cfc9b312211374a01beeafd5482822222820654645a1a7fbc18ead7769e7d6ae42a981735228ad45be6721740e1a5b7206ba6f87f3d3747465e04cd15c
7
- data.tar.gz: 876604b2fc3a6bd44009cf4ca3d746dc94c45947a3fa525db1c3db69d5337ee2c346381bf2e2984ceadbeac3bf9768db8639cc5f91220ff528834638793d8666
6
+ metadata.gz: 036114f10ef556602a66b0b0c407bc0f4acac45e353b650758eb29f23d567addfa53b0db734c3bce53660589e866ca57fc3f70b0fbfc88014669091305548d3c
7
+ data.tar.gz: b0abbce63d353477366626597c13cb2de29dfc61376d2dfe8b5dd0787ac248088029348bb207af3d468bb70c7517177ecbf18a9c11ce5e3a95c6f9d2db522ceb
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  Nothing new yet
4
4
 
5
+ ## [1.0.2] - 2022-01-27
6
+
7
+ - Add support of ActiveRecord `7.0.1`
8
+
5
9
  ## [1.0.1] - 2021-12-26
6
10
 
7
11
  - Add support of ActiveRecord `6.0.4.4`, `6.1.4.4` and `7.0.0`
data/README.md CHANGED
@@ -8,7 +8,7 @@ Currently, the implementation only works for ActiveRecord PostgreSQL adapter. Fe
8
8
 
9
9
  Because the implementation of this gem is a patch for `ActiveRecord::ConnectionAdapters::PostgreSQLAdapter` - carefully test its integration into your project. For example, if your project patches ActiveRecord or if some of your gems patches ActiveRecord - there might be conflicts in the implementation which could potentially lead to the data loss.
10
10
 
11
- Currently, the implementation is tested for `6.0.4.4` and `6.1.4.4` versions of ActiveRecord(see [TrxExt::SUPPORTED_AR_VERSIONS](lib/trx_ext/version.rb))
11
+ Currently, the implementation is tested for `6.0.4.4`, `6.1.4.4` and `7.0.1` versions of ActiveRecord(see [TrxExt::SUPPORTED_AR_VERSIONS](lib/trx_ext/version.rb))
12
12
 
13
13
  ## Requirements
14
14
 
@@ -5,29 +5,32 @@ module TrxExt
5
5
  # Wraps specified method in an +ActiveRecord+ transaction.
6
6
  #
7
7
  # @example
8
- # class Tilapia < Symbology::Base
9
- # wrap_in_trx def gnosis(number)
10
- # introspect(number, string.numerology(:kabbalah).sum)
8
+ # class User < ActiveRecord::Base
9
+ # class << self
10
+ # wrap_in_trx def find_or_create(name)
11
+ # user = find_by(name: name)
12
+ # user ||= create(name: name, title: 'Default')
13
+ # user
14
+ # end
11
15
  # end
12
16
  # end
13
17
  #
14
- # order = Tilapia.new
15
- # order.gnosis(93)
18
+ # User.find_or_create('some name')
16
19
  # # (0.6ms) BEGIN
17
- # # Introspection Load (0.4ms) SELECT "introspections".* FROM "introspections" WHERE "introspections"."id" = $1 LIMIT 1 [["id", 93]]
20
+ # # User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."name" = $1 LIMIT 1 [["name", 'some name']]
21
+ # # User Create (1.8 ms) INSERT INTO "users" ("name", "title") VALUES ($1, $2) RETURNING "id" [["name", "some name"], ["title", "Default"]]
18
22
  # # (0.2ms) COMMIT
19
- # # => 418
20
23
  #
21
24
  # @param method [Symbol] a name of the method
22
25
  # @return [Symbol]
23
26
  def wrap_in_trx(method)
24
27
  module_to_prepend = Module.new do
25
28
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
26
- def #{method}(...)
27
- trx do
28
- super
29
+ def #{method}(...)
30
+ trx do
31
+ super
32
+ end
29
33
  end
30
- end
31
34
  RUBY
32
35
  end
33
36
  prepend module_to_prepend
data/lib/trx_ext/retry.rb CHANGED
@@ -28,10 +28,10 @@ module TrxExt
28
28
  yield
29
29
  rescue => error
30
30
  error_classification = error_classification(error)
31
- if error_classification == :record_not_unique
32
- retries_count += 1
33
- end
34
31
  if retry_query?(error, retries_count)
32
+ if error_classification == :record_not_unique
33
+ retries_count += 1
34
+ end
35
35
  TrxExt.log("Detected transaction rollback condition. Reason - #{error_classification}. Retrying...")
36
36
  retry
37
37
  else
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TrxExt
4
- VERSION = "1.0.1"
5
- SUPPORTED_AR_VERSIONS = %w(6.0.4.4 6.1.4.4 7.0.0).freeze
4
+ VERSION = "1.0.4"
5
+ SUPPORTED_AR_VERSIONS = %w(6.0.4.7 6.1.5 7.0.2.3).freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trx_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Dzyzenko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-26 00:00:00.000000000 Z
11
+ date: 2022-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -143,8 +143,8 @@ licenses:
143
143
  metadata:
144
144
  allowed_push_host: https://rubygems.org
145
145
  homepage_uri: https://github.com/intale/trx_ext
146
- source_code_uri: https://github.com/intale/trx_ext/tree/v1.0.1
147
- changelog_uri: https://github.com/intale/trx_ext/blob/v1.0.1/CHANGELOG.md
146
+ source_code_uri: https://github.com/intale/trx_ext/tree/v1.0.4
147
+ changelog_uri: https://github.com/intale/trx_ext/blob/v1.0.4/CHANGELOG.md
148
148
  post_install_message:
149
149
  rdoc_options: []
150
150
  require_paths: