paranoia 2.5.3 → 2.6.1

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: 5a82e404509dd15068040f391a794122bc66343af8def462f0eb4e37851b670f
4
- data.tar.gz: fe04b171c8d485c18a4d41b2603780dfe15efebe1b3fd72d2a9074d0463642ae
3
+ metadata.gz: 7f3f587b5571dc6b69507b4b97de85c0c851bfe248048dbcc2ff792d578ebbca
4
+ data.tar.gz: ba5bb9bde79c1be27152df53d2d0be62e852b5e3801cb71d1b2b33fe8bfb9f6b
5
5
  SHA512:
6
- metadata.gz: e797a325e51bd15605087eae81c27c622df6b2b3e2c46466b6a3d2f4509e612a3712871e4140abb0530993b6773f59765cab1c10672572f3176c7e32401ecaab
7
- data.tar.gz: b040f4ea08e809a827172755f7913da31a93aa5a9f7207ac9626fa9dadf848e36b352eb7084687cbee3a553c7f33124e434d291c900ffca3cfbe1dba340d0fb3
6
+ metadata.gz: 42caeef276dfc15bcc15ca8fbd2dc8001ca7e24c3577d235d12bfa8cb175b082a4d585c07e4244f2d76acb9c49127c113a7f567bea7c60514a475cf3791ac789
7
+ data.tar.gz: 6655a5f44f71fe45e7df8df13545acd8706a8f105bece1e838c77722fbd8fe20ae6596f0e3961976b3bd2a3ed38c5a055230500c30599f8499d845be61c22a60
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # paranoia Changelog
2
2
 
3
+ ## 2.6.1
4
+
5
+ * [#535](https://github.com/rubysherpas/paranoia/pull/535) Allow to skip updating paranoia_destroy_attributes for records while really_destroy!
6
+ [Anton Bogdanov](https://github.com/kortirso)
7
+
8
+ ## 2.6.0
9
+
10
+ * [#512](https://github.com/rubysherpas/paranoia/pull/512) Quote table names; Mysql 8 has keywords that might match table names which cause an exception.
11
+ * [#476](https://github.com/rubysherpas/paranoia/pull/476) Fix syntax error in documentation.
12
+ * [#485](https://github.com/rubysherpas/paranoia/pull/485) Rollback transaction if destroy aborted.
13
+ * [#522](https://github.com/rubysherpas/paranoia/pull/522) Add failing tests for association with abort on destroy.
14
+ * [#513](https://github.com/rubysherpas/paranoia/pull/513) Fix create callback called on destroy.
15
+
3
16
  ## 2.5.3
4
17
 
5
18
  * [#532](https://github.com/rubysherpas/paranoia/pull/532) Fix: correct bug when sentinel_value is not a timestamp
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
@@ -1,7 +1,7 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/paranoia.svg)](https://badge.fury.io/rb/paranoia)
2
2
  [![build](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml/badge.svg)](https://github.com/rubysherpas/paranoia/actions/workflows/build.yml)
3
3
 
4
- **Notice:**
4
+ **Notice:**
5
5
 
6
6
  `paranoia` has some surprising behaviour (like overriding ActiveRecord's `delete` and `destroy`) and is not recommended for new projects. See [`discard`'s README](https://github.com/jhawthorn/discard#why-not-paranoia-or-acts_as_paranoid) for more details.
7
7
 
@@ -103,6 +103,14 @@ If you really want it gone *gone*, call `really_destroy!`:
103
103
  # => client
104
104
  ```
105
105
 
106
+ If you need skip updating timestamps for deleting records, call `really_destroy!(update_destroy_attributes: false)`.
107
+ When we call `really_destroy!(update_destroy_attributes: false)` on the parent `client`, then each child `email` will also have `really_destroy!(update_destroy_attributes: false)` called.
108
+
109
+ ``` ruby
110
+ >> client.really_destroy!(update_destroy_attributes: false)
111
+ # => client
112
+ ```
113
+
106
114
  If you want to use a column other than `deleted_at`, you can pass it as an option:
107
115
 
108
116
  ``` ruby
@@ -193,7 +201,7 @@ client.restore(:recursive => true)
193
201
  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
202
 
195
203
  ``` ruby
196
- Client.restore(id, :recursive => true. :recovery_window => 2.minutes)
204
+ Client.restore(id, :recursive => true, :recovery_window => 2.minutes)
197
205
  # or
198
206
  client.restore(:recursive => true, :recovery_window => 2.minutes)
199
207
  ```
@@ -1,3 +1,3 @@
1
1
  module Paranoia
2
- VERSION = '2.5.3'.freeze
2
+ VERSION = '2.6.1'.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
 
@@ -142,8 +144,8 @@ module Paranoia
142
144
  end
143
145
  alias :deleted? :paranoia_destroyed?
144
146
 
145
- def really_destroy!
146
- transaction do
147
+ def really_destroy!(update_destroy_attributes: true)
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|
@@ -156,12 +158,14 @@ module Paranoia
156
158
  # .paranoid? will work for both instances and classes
157
159
  next unless association_data && association_data.paranoid?
158
160
  if reflection.collection?
159
- next association_data.with_deleted.each(&:really_destroy!)
161
+ next association_data.with_deleted.find_each { |record|
162
+ record.really_destroy!(update_destroy_attributes: update_destroy_attributes)
163
+ }
160
164
  end
161
- association_data.really_destroy!
165
+ association_data.really_destroy!(update_destroy_attributes: update_destroy_attributes)
162
166
  end
163
167
  end
164
- update_columns(paranoia_destroy_attributes)
168
+ update_columns(paranoia_destroy_attributes) if update_destroy_attributes
165
169
  destroy_without_paranoia
166
170
  end
167
171
  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.3
4
+ version: 2.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - radarlistener@gmail.com
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-23 00:00:00.000000000 Z
11
+ date: 2022-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -91,7 +91,7 @@ homepage: https://github.com/rubysherpas/paranoia
91
91
  licenses:
92
92
  - MIT
93
93
  metadata: {}
94
- post_install_message:
94
+ post_install_message:
95
95
  rdoc_options: []
96
96
  require_paths:
97
97
  - lib
@@ -106,8 +106,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  - !ruby/object:Gem::Version
107
107
  version: 1.3.6
108
108
  requirements: []
109
- rubygems_version: 3.2.32
110
- signing_key:
109
+ rubygems_version: 3.4.0.dev
110
+ signing_key:
111
111
  specification_version: 4
112
112
  summary: Paranoia is a re-implementation of acts_as_paranoid for Rails 3, 4, and 5,
113
113
  using much, much, much less code.