paranoia 2.5.2 → 2.6.0

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: f6122d4c46b302086def8b0beb87e3ca9c06ae7a834d117d7bb7a8b0fce11f80
4
- data.tar.gz: 598b56a3af2868e8cbc8cb50f124b6d9d347dc2ca3af4a78012c01b9a6a281c0
3
+ metadata.gz: ad52996a9a12b6605d8179ad1ae5ef39cb7655d19d037884518800a02f6ff160
4
+ data.tar.gz: 3c9d2c4203e203b64bf0e24db1995ddfc431c8ed742ad96319f19eea2a62bc8a
5
5
  SHA512:
6
- metadata.gz: 7145f8fcc1e3a7810e96c772d92c8bc6624a30c4e3715ee85e3f34599585c3e2483c4f534790bf5031ff7f46f8c12b70d653182059f9896b5890d0e8c898a339
7
- data.tar.gz: 1537f8613522860bf7f4e571026b1b3fff29f936433d8d0e841780a92173c8749e86a1f5a30800907568d0394b0d618af00ea9f555d45c15841e751ba6906fd5
6
+ metadata.gz: ed7a78d7135fce0a513e0f5fb4c6c685c99ad788efa57e15dd9ae011d1dfce0d98bc41fd49b7688f3d706e6101b78824ada19ce3617359a085186e76acc0a2db
7
+ data.tar.gz: 2a24bfb1f5d1f9b8c5e588c86bf745ed80125167dfefc6ad5a10cc3b7a66da3ee50f85b7727cda74a5f92a9a1d1b3fac0defc4296b71b1dd7f8c9e9d8496831f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # paranoia Changelog
2
2
 
3
+ ## 2.6.0
4
+
5
+ * [#512](https://github.com/rubysherpas/paranoia/pull/512) Quote table names; Mysql 8 has keywords that might match table names which cause an exception.
6
+ * [#476](https://github.com/rubysherpas/paranoia/pull/476) Fix syntax error in documentation.
7
+ * [#485](https://github.com/rubysherpas/paranoia/pull/485) Rollback transaction if destroy aborted.
8
+ * [#522](https://github.com/rubysherpas/paranoia/pull/522) Add failing tests for association with abort on destroy.
9
+ * [#513](https://github.com/rubysherpas/paranoia/pull/513) Fix create callback called on destroy.
10
+
11
+ ## 2.5.3
12
+
13
+ * [#532](https://github.com/rubysherpas/paranoia/pull/532) Fix: correct bug when sentinel_value is not a timestamp
14
+ [Hassanin Ahmed](https://github.com/sas1ni69)
15
+ * [#531](https://github.com/rubysherpas/paranoia/pull/531) Added test case to reproduce bug introduce in v2.5.1
16
+ [Sherif Elkassaby](https://github.com/sherif-nedap)
17
+ * [#529](https://github.com/rubysherpas/paranoia/pull/529) Fix: Do not define a RSpec matcher when RSpec isn't present
18
+ [Sebastian Welther](https://github.com/swelther)
19
+
3
20
  ## 2.5.2
4
21
 
5
22
  * [#526](https://github.com/rubysherpas/paranoia/pull/526) Do not include tests files in packaged gem
@@ -19,7 +36,7 @@
19
36
 
20
37
  * [#516](https://github.com/rubysherpas/paranoia/pull/516) Add support for ActiveRecord 7.0, drop support for EOL Ruby < 2.5 and Rails < 5.1
21
38
  adding support for Rails 7
22
-
39
+
23
40
  [Mathieu Jobin](https://github.com/mathieujobin)
24
41
  * [#515](https://github.com/rubysherpas/paranoia/pull/515) Switch from Travis CI to GitHub Actions
25
42
 
@@ -31,7 +48,7 @@
31
48
 
32
49
  [Jörg Schiller](https://github.com/joergschiller)
33
50
 
34
- * [#483](https://github.com/rubysherpas/paranoia/pull/483) Update JRuby version to 9.2.8.0 + remove EOL Ruby 2.2
51
+ * [#483](https://github.com/rubysherpas/paranoia/pull/483) Update JRuby version to 9.2.8.0 + remove EOL Ruby 2.2
35
52
 
36
53
  [Uwe Kubosch](https://github.com/donv)
37
54
 
data/Gemfile CHANGED
@@ -20,7 +20,7 @@ if RUBY_ENGINE == 'rbx'
20
20
  end
21
21
  end
22
22
 
23
- rails = ENV['RAILS'] || '~> 5.2.0'
23
+ rails = ENV['RAILS'] || '~> 6.0.4'
24
24
 
25
25
  if rails == 'edge'
26
26
  gem 'rails', github: 'rails/rails'
data/README.md CHANGED
@@ -193,7 +193,7 @@ client.restore(:recursive => true)
193
193
  If you want to restore a record and only those dependently destroyed associated records that were deleted within 2 minutes of the object upon which they depend:
194
194
 
195
195
  ``` ruby
196
- Client.restore(id, :recursive => true. :recovery_window => 2.minutes)
196
+ Client.restore(id, :recursive => true, :recovery_window => 2.minutes)
197
197
  # or
198
198
  client.restore(:recursive => true, :recovery_window => 2.minutes)
199
199
  ```
@@ -1,4 +1,4 @@
1
- if Rails.env.test?
1
+ if defined?(RSpec)
2
2
  require 'rspec/expectations'
3
3
 
4
4
  # Validate the subject's class did call "acts_as_paranoid"
@@ -23,4 +23,4 @@ if Rails.env.test?
23
23
  end
24
24
  end
25
25
 
26
- end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = '2.5.2'.freeze
2
+ VERSION = '2.6.0'.freeze
3
3
  end
data/lib/paranoia.rb CHANGED
@@ -40,7 +40,7 @@ module Paranoia
40
40
  # these will not match != sentinel value because "NULL != value" is
41
41
  # NULL under the sql standard
42
42
  # Scoping with the table_name is mandatory to avoid ambiguous errors when joining tables.
43
- scoped_quoted_paranoia_column = "#{self.table_name}.#{connection.quote_column_name(paranoia_column)}"
43
+ scoped_quoted_paranoia_column = "#{connection.quote_table_name(self.table_name)}.#{connection.quote_column_name(paranoia_column)}"
44
44
  with_deleted.where("#{scoped_quoted_paranoia_column} IS NULL OR #{scoped_quoted_paranoia_column} != ?", paranoia_sentinel_value)
45
45
  end
46
46
  alias_method :deleted, :only_deleted
@@ -58,8 +58,8 @@ module Paranoia
58
58
  end
59
59
 
60
60
  def paranoia_destroy
61
- transaction do
62
- run_callbacks(:destroy) do
61
+ with_transaction_returning_status do
62
+ result = run_callbacks(:destroy) do
63
63
  @_disable_counter_cache = deleted?
64
64
  result = paranoia_delete
65
65
  next result unless result && ActiveRecord::VERSION::STRING >= '4.2'
@@ -73,7 +73,9 @@ module Paranoia
73
73
  @_disable_counter_cache = false
74
74
  result
75
75
  end
76
- end
76
+ raise ActiveRecord::Rollback, "Not destroyed" unless self.deleted?
77
+ result
78
+ end || false
77
79
  end
78
80
  alias_method :destroy, :paranoia_destroy
79
81
 
@@ -138,12 +140,12 @@ module Paranoia
138
140
  end
139
141
 
140
142
  def paranoia_destroyed?
141
- deletion_time != paranoia_sentinel_value
143
+ paranoia_column_value != paranoia_sentinel_value
142
144
  end
143
145
  alias :deleted? :paranoia_destroyed?
144
146
 
145
147
  def really_destroy!
146
- transaction do
148
+ with_transaction_returning_status do
147
149
  run_callbacks(:real_destroy) do
148
150
  @_disable_counter_cache = paranoia_destroyed?
149
151
  dependent_reflections = self.class.reflections.select do |name, reflection|
@@ -296,12 +298,16 @@ ActiveSupport.on_load(:active_record) do
296
298
  self.class.paranoia_column
297
299
  end
298
300
 
301
+ def paranoia_column_value
302
+ send(paranoia_column)
303
+ end
304
+
299
305
  def paranoia_sentinel_value
300
306
  self.class.paranoia_sentinel_value
301
307
  end
302
308
 
303
309
  def deletion_time
304
- send(paranoia_column)
310
+ paranoia_column_value.acts_like?(:time) ? paranoia_column_value : deleted_at
305
311
  end
306
312
  end
307
313
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paranoia
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - radarlistener@gmail.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-02 00:00:00.000000000 Z
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord